Reputation: 620
Is it possible to listen to system's volume and music control events (Next/Prev)? I am playing a song from MediaLibrary using MediaPlayer but how to capture Next\Prev button press event? Thanks!
Upvotes: 1
Views: 771
Reputation: 2727
Volume Events
It's not possible to listen for (or subscribe to) the system volume events. You cannot find out the current system volume or know when the volume keys on the phone are pressed.
If your app is playing music using a MediaElement
, for example, you simply play the sounds or music blindly not knowing what the system volume is.
Developers have voted to improve this API which will hopefully happen in a future release.
Music Events
If your app is playing music using the BackgroundAudioPlayer
, you can subscribe to the PlayStateChanged
event. You can detect if music is playing using the MediaPlayer class. Although this is an XNA library, it works in WP7 and WP8.
If the user starts music in your app, it will stop whatever music the system is playing and take over. The opposite is also true. If your app is playing music, and the user goes to another music app, your BackgroundAudioPlayer
will receive PlayState.Stopped
.
Upvotes: 1