Jump to content

How to play audio through event?


quanliking

Recommended Posts

I am developing a 'Service evaluation system' use uniGUI.

I tried to modify example "HTML5 Audio", but it not work. I can hear sound by click the button with my finger, but can not hear sound by triggering by an event, for example MQTT publish event.I think it is Chrome browser js restrictions.

Can anybody provide examples?  Thanks.

Link to comment
Share on other sites

Thanks, Sherzod, irigsoft

I am use sgcWebSocket for MQTT communication, I can not give the example by now.

because sgcWebSocket publish event handler can not execute the playsound logic right(can not hear sound), so I put a timer with a MainForm variable(not global variable) named 'IsAudioOn', where 'IsAudioOn' is true, timer play sound.

It seem no problem at the surface, but I have 64 win10 terminals, and I find only part of terminals play sound, others could play sounds only after I touch the physical 'volume control key' with my hand. 

It is weird. I tried many times and reached a conclusion that that browser play sound is not reliable when you have many devices to play sounds, not work every time.

Now I have Client + Browser architecture, Client play sounds with sgcWebSocket MQTT for communications and Browser embed in Client do business logic with sgcWebSocket MQTT for communications.It is compromise that part business logic(play sound)move to Client, but it is reliable.

 

  

    

Link to comment
Share on other sites

  • 4 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...