Reputation: 18266
One of the requirements for windows store apps is that they support suspending. My app is marked as a background audio task, so it doesn't suspend when left alone, but it is supposed to suspend when the audio is paused.
I can't find out how to "tell Windows" when it can or can't suspend. How do I have my background audio application pass the package validation?
Upvotes: 1
Views: 398
Reputation: 4801
I was working on a Windows Store app recently (online radio app) with the same Background Audio Task support, and kept failing the WACK - it turns out that you can't have your MediaElement for the background audio be set to AutoPlay = true, or you will constantly fail the suspend test.
This (and some other tips) in this handy yet not publicised enough list of tips: http://www.slideshare.net/msdnbelux/windows-store-top-learnings-from-the-first-belgian-windows-8-apps
Upvotes: 0
Reputation: 7024
To enable background audio you must register handlers for the Media Control button events. These are in the Windows.Media.MediaControl class, specifically the PlayPressed, PausePressed, PlayPausePressed (some hardware has a single button for both), and StopPressed. If you don't have handlers for these, then background audio won't work. With the handlers, Windows will know when the audio is paused, and will then be able to suspend you. Fortunately, by virtue of your Play[Pause]Pressed handlers, Windows will also resume the app when playback starts again.
These events work for both hardware and on-screen buttons, e.g.
If you have multiple tracks you are playing, then registering handlers for NextTrackPressed and PrevTrackPressed controls whether the forward/back buttons are enabled here. The AlbumArt, TrackName, and ArtistName fields in the MediaControl class are also used to set the data in the medial control UI above.
Upvotes: 3