How to pass html5 code as a string (dynamically) to showWebPopup and play audio using html5?

I need to be able to create html5 code dynamically and pass it to showWebPopup. I could do this if showWebPopup accepted the code as a string but because of the multiple "s it gives an error. I cant do it with an html file because I need to create the html5 code dynamically. How can I do this?

Also I tested the following html code, by creating the file i see the webpopup but the audio does not play. The code works in chrome. The url below is fake. 

\<audio src="http://radiourl" autoplay\>\</audio\>

Why doesn’t it work with showWebPopup?

Thank You.

I tried everything. I cant get audio to play using html code and showWebPopup. 

 local options = { baseUrl = system.ResourceDirectory, -- default: nil --hasBackground = false, -- default: true autoCancel = false, -- default: true (android) urlRequest = listener\_function, -- default: nil } native.showWebPopup( "stream.html", options)

Is it not possible?

My current html code

\<audio src="http://radiofakeurl" autoplay\>\<em\>Sorry, your browser doesn't support HTML5 audio.\</em\>\</audio\>

The error message is not displayed. I have added the internet permission and the code works on chrome just fine.

Ok I think the reason why the code does not work is because Android does not allow audio to auto play. It wants the user to interact with the webview before playing the audio. I want it to auto play. Cant figure it out. Used javascript still nothing.

I need to call 

WebView.getSettings().setMediaPlaybackRequiresUserGesture(false)

How can I do this in lua?

Why not use Corona SDK’s APIs to play audio?

They dont support live audio feeds.

Can’t be done with Corona SDK APIs and Can’t be done with webview/html5

Instead of using enterprise I’d rather just go native

You should be able to write out a chunk of HTML from Corona to the folder system.TemporaryDirectory and then have your native.newWebView() read it back in to power your webView.

Rob

I tried everything. I cant get audio to play using html code and showWebPopup. 

 local options = { baseUrl = system.ResourceDirectory, -- default: nil --hasBackground = false, -- default: true autoCancel = false, -- default: true (android) urlRequest = listener\_function, -- default: nil } native.showWebPopup( "stream.html", options)

Is it not possible?

My current html code

\<audio src="http://radiofakeurl" autoplay\>\<em\>Sorry, your browser doesn't support HTML5 audio.\</em\>\</audio\>

The error message is not displayed. I have added the internet permission and the code works on chrome just fine.

Ok I think the reason why the code does not work is because Android does not allow audio to auto play. It wants the user to interact with the webview before playing the audio. I want it to auto play. Cant figure it out. Used javascript still nothing.

I need to call 

WebView.getSettings().setMediaPlaybackRequiresUserGesture(false)

How can I do this in lua?

Why not use Corona SDK’s APIs to play audio?

They dont support live audio feeds.

Can’t be done with Corona SDK APIs and Can’t be done with webview/html5

Instead of using enterprise I’d rather just go native

You should be able to write out a chunk of HTML from Corona to the folder system.TemporaryDirectory and then have your native.newWebView() read it back in to power your webView.

Rob