windows phone 8 - Play a selected song in MediaLibrary WP8 -
here problem : have longlistselector list songs medialibrary , selectionchanged event. when user taps on song longlistselector, plays song once, then stops. i'd play next song medialibrary once selected song finished
here longlistselector :
<phone:longlistselector x:name="llssongs" selectionchanged="llssongs_selectionchanged" margin="0,-30,0,0"> <phone:longlistselector.itemtemplate> <datatemplate> <stackpanel margin="5,5,5,5"> <textblock text="{binding name}" fontsize="20" foreground="black"/> <textblock text="{binding artist}" fontsize="15" opacity="0.75" foreground="black"/> </stackpanel> </datatemplate> </phone:longlistselector.itemtemplate> </phone:longlistselector>
and selectionchanged method
private void llssongs_selectionchanged(object sender, selectionchangedeventargs e) { song _selectedsong = llssongs.selecteditem song; mediaplayer.play(_selectedsong); }
take @ articles
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394039(v=vs.105).aspx http://developer.nokia.com/community/wiki/audio_recording_and_playback_options_in_windows_phon
edit:
based on usage of medialibrary
, mediaplayer
xna.framework.media namespace classes, take advantage of mediaplayer's mediastatechanged event.
private void mediaplayeronmediastatechanged(object sender, eventargs e) { if (mediaplayer.state == mediastate.stopped) { mediaplayer.play(nextsong); } }
since collection holds song
's returned medialibrary.songs, songcollection nextsong next index in data bound collection.
Comments
Post a Comment