- This topic has 5 replies, 2 voices, and was last updated 11 years, 7 months ago by
BryanBudelon.
-
AuthorPosts
-
BryanBudelonMemberHello people!
I’m doing tests with widget audio, but have one problem. When create ‘player’ of audio by code, he not play in smartphone, only testing.
Below is the project:
Attachments:
You must be logged in to view attached files.November 19, 2013 at 6:59 am #344583
BryanBudelonMemberUP!
November 19, 2013 at 9:52 am #344592
support-michaelKeymasterA couple of bugs in your code:
1) your media url does not work for me. See the screenshot below that shows the media does not load. I tried it outside of the mobione app and it also failed. Switching to a known media stream works.
2) in a native app you need to wait for the cordova/phonegap api to initialize before you
// I reimplemented your code to respect the requirement that you should not use the Cordova // api until you receive the deviceready event. I also switched to a streaming URL that is // very reliable. Avoid wasting time with garbage in, garbage out media sources. Use only sources // that are known to work before you start messing with other sources will save everyone time. /** * Called when document is loaded. */ phoneui.documentReadyHandler = function() { document.addEventListener("deviceready",onDeviceReady,false); } //var url = 'http://audio.tupa.am.br:9986/;'; // <-- does not load var url = 'http://vprbbc.streamguys.net:80/vprbbc24.mp3'; // BBC stream var media; function createMedia() { if (media) return; media = phoneui.createMedia(url); } function onDeviceReady() { createMedia(); } function playStreaming() { if (!media) { alert('media is not initialized'); return; } media.play(); } function stopStreaming() { if (media) media.stop(); }
November 19, 2013 at 10:55 am #344596
BryanBudelonMemberAbout streaming, he is offline temporarily, but works.
Another question: Should work in backgroud with this mode, right? But this is not happening.
Thanks for help! 😀
November 19, 2013 at 11:29 am #344600
support-michaelKeymaster>About streaming, he is offline temporarily, but works.
The issue I wasted time checking out the stream and it is dead – waste of time. Let’s focus only on reliable services.
>Should work in backgroud with this mode, right? But this is not happening.
Depends upon what your definition of background is. If you mean play audio when some other application is running in foreground, then no that is not supported. But if you want the application to play media without the user pressing a play button do something simple like add playStream() as shown below in the deviceready handler:
function createMedia() { if (media) return; media = phoneui.createMedia(url); playStreaming(); }
November 19, 2013 at 12:25 pm #344605
BryanBudelonMemberI would play audio when some other application is running with widget audio, because
using this way http://www.genuitec.com/support-genuitec/viewtopic.php?f=14&t=6013
occurs very delay between the click and start reproducing. -
AuthorPosts