We are experimenting problems with Audio component when playing sound on iPhone and iPad browser (iOs 14.xxx). We tried different format (mp3, wav, m4a) but no sound in iPhone/iPad browser. Everything run properly in all browsers on Windows. Please advice ?
Regards,
Stefano
As long as the Window or Page is created in Program.Main you’ll be able to access it using App.MainPage or App.Window1
If your audio and button are on the same level, you can use this so you don’t have to worry if it’s on a page or window:
this.getParent().audio1.play();
I would recommend using the debugger; keyword and placing it in your JavaScript code so you can play around with the console in Chrome Dev tools.
Some helpful links:
JavaScript Object Model in Wisej:
https://docs.wisej.com/docs/concepts/javascript-object-model
Debugger keyword:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger
HTH,
Levie
Hi Stefano,
Playing audio on iOS Safari requires user interaction from the client. You can’t use Wisej to initially play the audio because it’s part of a callback (the play gets blocked, see the console errors). Wisej uses polling or a WebSocket connection to receive changes from the server (and to process commands like the server-side audio.play() call). This comes in the form of a callback through the AJAX request or the WebSocket’s message processing.
You can however play audio through a callback after the client has interacted with the audio element or triggered play() through a client-side event.
So if your application requires users to login or click a button at all, you can add to the client-side JS “execute” event something like:
App.Window1.audio1.play(); App.Window1.audio1.pause();
This satisfies the requirement of interacting with the element and dom (though no audio will be played here).
You can then go on later in your application and call audio1.Play() in your C# or VB code normally and it should play without an issue.
Please let me know if you have any issues with this!
Best,
Levie
Hi Levi,
thanks for the sample. Does it run in Window or just in a Page?
s.g.
Hi Stefano,
Here’s the sample. Let me know if you have any issues with it!
Best,
Levie
Hi Levi,
could you provide some code sample ?
Regards,
Stefano
Additionally,
You could accomplish auto-playing the audio through a custom WKWebView wrapper like the one provided as part of the Wisej Mobile package. It overrides a lot of the default Safari functionality to give developers more control over their application.
If you’re interested, you can contact sales AT wisej DOT com.
HTH,
Levie
Hi Stefano,
You can’t call Audio.Play() from the server on iOS. Safari doesn’t allow async calls to play the audio (https://developer.apple.com/forums/thread/94522). You can see it throws an error in the console (see attached image).
You can get around it by adding a ClientEvent for the “execute” event to a button with something like this:
App.MainPage.Audio1.play();
It should work fine as long as you trigger audio.play() from the client and not through a callback.
If you need more help with this, please let me know and provide some more details on how you’re using it!
Best,
Levie
Please login first to submit.