Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:36:05+00:00 2026-06-18T12:36:05+00:00

I have read previous posts on this and documents by microsoft but cannot seem

  • 0

I have read previous posts on this and documents by microsoft but cannot seem to get my app to run Sound in the background. It plays 100% but when ever the app is then suspended the music also stops. I have added “Background Tasks” declarations selecting Audio and my audio tag looks like this

<audio id="musicplayr" msAudioCategory="BackgroundCapableMedia" controls="controls"><source src="song.mp3"/> </audio

and finally my javascript includes the references to MediaControls

var MediaControls = Windows.Media.MediaControl;

        // Add event listeners for the buttons
        MediaControls.addEventListener("playpressed", play, false);
        MediaControls.addEventListener("pausepressed", pause, false);
        MediaControls.addEventListener("playpausetogglepressed", playpausetoggle, false);

        // Add event listeners for the audio element
        document.getElementById("musicplayr").addEventListener("playing", playing, false);
        document.getElementById("musicplayr").addEventListener("paused", paused, false);
        document.getElementById("musicplayr").addEventListener("ended", ended, false);

and below in the code i have the event handlers

// Define functions that will be the event handlers
function play() {
    document.getElementById("musicplayr").play();
}
function pause() {
    document.getElementById("musicplayr").pause();
}

function playpausetoggle() {
    if(MediaControls.isPlaying === true) {
        document.getElementById("musicplayr").pause();
    } else {
        document.getElementById("musicplayr").play();
    }
}

function playing() {
    Windows.Media.MediaControl.isPlaying = true;
}

function paused() {
    Windows.Media.MediaControl.isPlaying = false;
}

function ended() {
    Windows.Media.MediaControl.isPlaying = false;
}

*Note musicplayr is the reference for the html5 tag

Any help appreciated why this is not working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:36:06+00:00Added an answer on June 18, 2026 at 12:36 pm

    You also need an event handler for the stoppressed event. Without any of the four handlers–playpressed, pausepressed, playpausetogglepressed, and stoppressed–background audio won’t be enabled. See http://social.msdn.microsoft.com/Forums/en-IN/winappswithhtml5/thread/2ca0c122-df31-401c-a444-2149dd3e8d68 on the MSDN forums where the same problem was raised.

    .Kraig

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read all the previous posts about this exact topic, but I still
I have already read all the previous similar posts but I couldn't find a
This question might seem a repeat of previous ones. I have read through a
Apologies, but I have searched and read previous answers on this question but couldn't
I have read a bunch of forums on this but none have solved my
I have read the previous posts about using the RequireHttpsAttribute to secure individual controllers:
I have read from previous posts [ 1 , 2 , 3 ] that
I have read this post but it won't fix my problem. Skip going back
I am sure this is straight forward but I just cant seem to get
[I have read previous posts on MEF vs MAF vs DI etc, they aren't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.