So I would like to allow the user to select a song from their media library and play it back at a variable volume. From what I understand, the following are true:
- Songs are accessed via an instance of the MediaLibrary
- Songs can be played with MediaPlayer.Play()
- Changing MediaPlayer.Volume has no effect on songs from the MediaLibrary (as of XNA 4.0)
- There is a System.Windows.Controls.MediaElement control but its source is either a stream or a Uri
Has anyone found a way around these limitations, to play a Song from the MediaLibary at different volumes? I can only think of two ways this might be possible. One, somehow wrap a Stream around the Song and feed it to a MediaElement (either directly or by copying the Song to isolated storage and streaming it from there), or two, get access to the MediaLibary with a Uri. Does anyone know if either of these is possible?
Also, I haven’t looked at Microsoft.Phone.BackgroundAudio, is there anything useful in there?
Thanks.
The user is in complete control over the volume of what comes out of the phone.
The value of
MediaPlayer.Volumeis relative to the volume that the user has set. (I always set this to 1 and have yet to find a real life need to set this to anything else.)Yes, this means that you can’t do what you’re trying to.
If you could it woudl mean that even if the user had turned the volume on the device to very quiet your app could suddenly play a sound much louder. This would not be a predictable user experience and probably not what the user desires.
And no, there’s no alternative with background audio and no, you can’t get a URI to an item in the MediaLibrary.