Radio streams not playing in background


  • Hi,

    I'm trying to make my app play radio streams in background but with no success so far. I did follow the steps from http://msdn.microsoft.com/en-us/library/windows/apps/hh700367.aspx . I set the declaration in appx manifest and HTML looks something like:

    <audio id="playeraudio" preload="false" autoplay="false" msaudiocategory="BackgroundCapableMedia" src="http://vipicecast.yacast.net/virginradio_128"></audio>

     That stream works when the app is in front, but when I go to desktop, the playback stops.


    Friday, June 29, 2012 4:06 PM


  • Found the answer. Apparently I have to get attached to all events listed bellow:

    var mediaControl = Windows.Media.MediaControl; mediaControl.addEventListener("playpausetogglepressed", playpause, false); mediaControl.addEventListener("playpressed", play, false);

    mediaControl.addEventListener("stoppressed", stop, false);

    mediaControl.addEventListener("pausepressed", pause, false); function playpause() { if (!audtag.paused) { audtag.pause(); Windows.Media.MediaControl.isPlaying = false; } else { audtag.play(); Windows.Media.MediaControl.isPlaying = true; } } function play() { audtag.play(); Windows.Media.MediaControl.isPlaying = true; } function stop() { // Handle the Stop event and print status to screen. WinJS.log && WinJS.log("Stop Received (but a media element can't 'stop', so just diplaying text.", "sample", "status"); } function pause() { audtag.pause(); Windows.Media.MediaControl.isPlaying = false; }

    • Marked as answer by Suhov Lucian Monday, July 2, 2012 9:56 AM
    Monday, July 2, 2012 9:55 AM