Question

I try to make a Windows Phone app which plays sounds to help you fall asleep. I use SoundEffect class so that I can mix multiple sound files. The certification requirements says

"An app can play media in the background while it is running even when its primary function is not related to music or video. An app that plays music, audio, or sound effects must meet the following requirements:" "The SoundEffect class must not be used to play a continuous background music track in an app." So if the SoundEffect class plays continuos music under locked screen is ok, right?

I made a timer with DispatcherTimer class, so that the user can set the time when sounds stop, so the battery won't go dead. But the certification requirements says

"All apps that run under a locked screen must stop any UI updates, active timers, and other non-critical processing when notified that the screen is locked." So I can't use that, because my app has to be able to run under locked screen. What can I do to stop the music playing after a time interval or at a set time?

Was it helpful?

Solution

and other non-critical processing

Turning off the music is a key feature of your app, and therefore is a critical processing.

That said, since the DispatcherTimer has a strong dependance on the UI, I don't know if it will run properly under the lock screen. You should use a classical timer instead, or even better, just a thread with a Thread.Sleep instruction.

For instance, if you must stop the music two hours after the screen is locked, start a thread in the Obscured event and make it sleep for two hours:

private void TurnOffMusic()
{
    Thread.Sleep(1000 * 60 * 60 * 2); // Sleep for two hours
    // Turn off the music
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top