Browser-Phone icon indicating copy to clipboard operation
Browser-Phone copied to clipboard

selective ringtone

Open vieridipaola opened this issue 2 years ago • 3 comments

Hi,

Would it be possible to selectively ring a wav file according to the incoming caller's ID/number?

I personally don't need a GUI setting for this. However, a phoneOptions setting that defines, say, a regexp that would match a caller's number or ID and play a different wav file? The default would still be the same, but if one defines a regexp then a different wav could be played instead. It could even be an array of regexp so multiple wav ring files could be used.

Vieri

vieridipaola avatar Jun 01 '22 08:06 vieridipaola

You can now disable the ring tone, and use the web hooks to play your own ring tone according to your algorithm.

Personalised tine tones has been a todo item for a while, but hasn't gathered much interest.

InnovateAsterisk avatar Jun 07 '22 09:06 InnovateAsterisk

Yes, it works great when I put the logic into my custom web_hook_on_invite function. However, I still need to hack phone.js because I need to add this:

function InitUi(){

    // Custom line:
    if(typeof ui_hook_on_init !== 'undefined') ui_hook_on_init();

and then in my custom "pre js" script I do something like this:

var ui_hook_on_init = function() {
    // custom ringtones:
    audioBlobs.Ringtone2 = { file : "Ringtone_2.mp3", url : hostingPrefex +"media/Ringtone_2.mp3" }
    audioBlobs.CallWaiting2 = { file : "Tone_CallWaiting2.mp3", url : hostingPrefex +"media/Tone_CallWaiting2.mp3" }

That's because I want the PreloadAudioFiles function to load these custom audio files.

My custom web_hook_on_invite function will then handle the audioBlobs array accordingly (after disabling EnableRingtone).

Can you please include the ui_hook_on_init and ui_hook_on_ready calls in phone.js as I suggested in another "issue" on Github? Do you see any inconvenience in doing so?

Thanks

vieridipaola avatar Jun 10 '22 11:06 vieridipaola

What I mean by this is that there's no point in duplicating code in "pre js scripts" if it's already doing the job in phone.js. That's why I'd like to use PreloadAudioFiles with my previous example using ui_hook_on_init.

Also, I'm currently duplicating code to play audio files for ringing and callwaiting (taken from the ReceiveCall function). I think it would be best to define a new playAudioFile function in phone.js so it can be reused in any "pre js script" (or in phone.js itself) by simply passing it an audio "blob" and/or url.

It's just a thought.

vieridipaola avatar Jun 13 '22 07:06 vieridipaola