webview with audio.play() only works first time entering scene on iOS device

Hi,

I use native.newWebView (but also tried with native.showWebPopup; same behaviour) to open a local html file which I use to stream audio by calling it with the right stream URL. 

There seems to be an issue when I change scenes on my iOS device. It works perfectly on the corona simulator.

Expected behaviour (I have added the webview request in various scenes)

  • when performing a webview:request with a unique URL (i.e. “audioplay.html?a=”…os.time()…"?snipAudio="…varHoldingNewStreamURL), the already loaded newwebview (loaded in main scene and not destroyed across scenes) should start playing the new audio stream. This works in the simulator for every scene.

Behaviour on an actual iOS device:

  • scene1: I can hear the audio play just fine; I can even use different requests to make the audio change in this scene

  • switch to scene 2: I can hear the new requested audio play just fine

  • switch back to scene 1: no more audio (no error either) - webview is visible though (with changed contents)

  • switch to any other scene that uses webview to stream audio from this point forward: no more audio - webview is visible though (with changed contents)

As said, it works perfectly in the simulator; I have tried using showwebpopup; cancelling them or removing them when exiting scenes and re-initiating them in each scene; initiating the newwebview only once in main.lua and never close them etc. But behaviour is always the same on the iOS device.

I’m using iOS 8.2, 8.3 and corona build 2014.2511. 

It may have to do with the fact that on iOS you’d need special permission on the webview to play audio without user interaction, but why would it work the first time (or second scene time even)?

Anyone has similar experiences with this? I’m getting rather desperate, having tried everything (at least, that’s what it feels like)

See below for the local html file that I use for the audio playing:

<html>

<head>

<title></title>

<script type=“text/javascript”>

function getAudioFile()

{

var audio1 = document.getElementById(‘audio1’);

audio1.pause();

audio1.currentTime = 0;

var source1 = document.getElementById(‘audiosrc1’);

var srcComm = location.search.split(‘snipAudio=’)[1];

if (srcComm==“stop”) {

source1.src="";

audio1.stop();}

else {

source1.src=srcComm;

audio1.play();}

}

</script>

</head>

<body>

<audio id=“audio1” autoplay=“false”>

<source id=“audiosrc1” src="" type=“audio/mpeg” />

</audio>

<script type=“text/javascript”>getAudioFile();</script>

</body>

</html>

thanks,

Rik

Were you able to make it work?

No, unfortunately not. In the end, I reverted back to downloading the audio snippets (they are preview mp3), then use them as appropriate and then delete them when no longer needed in the session. Good thing is that I do not need webviews in that case (so I feel to have more control), but really wanted to get the streaming audio to work.

Were you able to make it work?

No, unfortunately not. In the end, I reverted back to downloading the audio snippets (they are preview mp3), then use them as appropriate and then delete them when no longer needed in the session. Good thing is that I do not need webviews in that case (so I feel to have more control), but really wanted to get the streaming audio to work.