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!
1 Answers
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
.

- 1
- 1

- 2,712
- 2
- 18
- 37
-
Thanks. I actually use MediaPlayer to play songs from MediaLibrary. Does MediaElement can play songs from local MediaLibrary? For BAP, it doesn't have constructor that take SongCollection and only play songs with known url which is impossible to get using MediaLibrary. I can get PlayState like stop/pause/playing but I don't know if user has pressed Next/Prev on the system playing control. With all these constraint, I feel that Microsoft assumes only Micrsoft can provide Music Player but not others. – thsieh Aug 04 '13 at 22:10