I am trying to play the selected media from a PlayList if the selected index is not zero, as shown below:
if (playList.Items.Count == 0)
{
setPlayList();
if (selectedIndex!= 0)
{
if(custMediaElement.Playlist!=null)
custMediaElement.GoToPlaylistItem(selectedIndex);
}
}
But I get a Null Reference exception when trying to jump to a PlayList element using the selected index, as described above. This works fine if I don’t use it custMediaElement.GoToPlaylistItem(selectedIndex);, but in this case Media Player always plays the 1st element, no matter which song I select from the list.
Below are a few details from Stack Trace:
ExpressionMediaPlayer.MediaPlayer.DoOpenPlaylistItem(PlaylistItem playlistItem)
at ExpressionMediaPlayer.MediaPlayer.GoToPlaylistItem(Int32 playlistItemIndex)
Thank,
Subhen
source
share