views:

244

answers:

2

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

+1  A: 

Was not that Complicated , was just unsure of the methods. So answer goes like below:

  int currentPlayListItem = listBox.SelectedIndex;
 custMediaElement.GoToPlaylistItem(currentPlayListItem);
Subhen
A: 

I'm kind of trying to do something similar. What CustomMediaPlayer did you use? When I try using Expression Media Player it plays .wmv and .mp4 files but NOT .mpeg or .mpg file extensions. HELP!

csahni2
Since this isn't really an answer to the question asked above, you're better off posting this as a separate question. More people are likely to see your question and answer it well if you ask a new question than if you hide a question in the answers to another question. Be sure to provide all the details that could be relevant to your problem, like how exactly you're trying to play those files/...
sth
Agree with sth Feedback
Subhen
Thanks, I made a separate questions titled "ExpressionMediaPlayer to play .mpeg".. please help!
csahni2