How to set the PlayList Index for Mediaplayer(ExpressionMediaPlayer:Mediaplayer)
Posted
by Subhen
on Stack Overflow
See other posts from Stack Overflow
or by Subhen
Published on 2010-05-06T10:22:44Z
Indexed on
2010/05/06
10:28 UTC
Read the original article
Hit count: 583
Hi,
I have a Mediaplayer control on my XAML page like below:
<CustomMediaElement:CustomMediaPlayer
x:Name="custMediaElement"
VerticalAlignment="Center"
Width="600" Height="300" Visibility="Collapsed" />
Now I am ble to set the playList by using setPlayList()
method like below:
private void setPlayList()
{
IEnumerable eLevelData = null;
eLevelData = pMainPage.GetDataFromDictonary(pMainPage.strChildFolderID);
foreach (RMSMedia folderItems in eLevelData)
{
string strmediaURL = folderItems.strMediaFileName;
if (hasExtension(strmediaURL) == "wmv" || hasExtension(strmediaURL) == "mp4" || hasExtension(strmediaURL) == "mp3" || hasExtension(strmediaURL) == "mpg")
{
PlaylistItem playListItem = new PlaylistItem();
string thumbSource = folderItems.strAlbumcoverImage;
playListItem.MediaSource = new Uri(strmediaURL, UriKind.RelativeOrAbsolute);
playListItem.Title = folderItems.strAlbumName;
if (!string.IsNullOrEmpty(thumbSource))
playListItem.ThumbSource = new Uri(thumbSource, UriKind.RelativeOrAbsolute);
playList.Items.Add(playListItem);
}
}
custMediaElement.Playlist = playList;
}
Now , I want to change the PlayListIndex of Mediaplayer, when user clicks on a listBox Item , which contains the title of all the songs.
When the user clicks on the third song title from the songs Title List the mediaPlayer should play the third song , or if the user cliks on 7th song title, the mediaPlayer should play the 7th song.
My motto is to pick up the Selected index from the listbox and assign it to the PlayList Index of mediaPlayer.
While I add a watch to playList
I am able to see , playList
, Items
, [0]
PlaylistIndex 1
playList
, Items
, [1]
PlaylistIndex 2
But While I am trying to set it from the code , the same property PlaylistIndex
seems unavailable. Please help.
Thanks, Subhen
© Stack Overflow or respective owner