user1153974
user1153974

Reputation: 13

populate media element with media library song

I'm trying to populate a media element with a medialibary song

but the media element source property wont accept anything i try has it it, the source property seems to load filepaths or urls btu i want to access and load a song from the media libary

if another approach is easier what im actually trying to do is, load a mediaplayer song into a slider

Thanks Alex

Upvotes: 1

Views: 790

Answers (2)

keyboardP
keyboardP

Reputation: 69372

To play any Song file retrieved from the MediaLibrary, you have to use the MediaPlayer. Unfortunately, the MediaPlayer has no Position property which means you cannot programmatically set the position of the audio file. This means that it's not possible to attach a slider to the MediaPlayer in order to use it to change position.

As MyKuLLSKI mentioned, you can use a MediaElement to change the position of an audio file. However, you can't use a file retrieved from the MediaLibrary in the MediaElement (you can only use a stream or a file you have included within the XAP).

So, in your case, if you need to retrieve a song from the MediaLibrary, then you are limited to the methods available to the MediaPlayer (which does not support positioning).

Upvotes: 2

MyKuLLSKI
MyKuLLSKI

Reputation: 5325

I'm sorry to say, but even in Mango this is 100% NOT possible. You can only stream media off the internet or from your XAP.

To bind the slider value you would bind the Position of the mediaelement to it

<MediaElement x:Name="MediaPlayer"/>
<Slider Value="{Binding ElementName="MediaPlayer", Path="Position", Mode="TwoWay"/>

Upvotes: 3

Related Questions