Null reference exception While Navigating to PlayListItem

自作多情 提交于 2019-12-11 06:25:40

问题


I am trying to play the selected media from PlayList,if the selected index is not zero as below:

if (playList.Items.Count == 0)
   {
      setPlayList();
          if (selectedIndex!= 0)
               { 
                  if(custMediaElement.Playlist!=null)
                  custMediaElement.GoToPlaylistItem(selectedIndex);
               }
    }

But I am getting a Null reference Exception while trying to go to PlayList Item with the help of selected index , as explained in top. This works fine if I don't use custMediaElement.GoToPlaylistItem(selectedIndex); but in that case the Media Player Always plays the 1st Item , No matter , Which ever Song I select from the List Box.

Below is few details from Stack Trace:

ExpressionMediaPlayer.MediaPlayer.DoOpenPlaylistItem(PlaylistItem playlistItem)
at ExpressionMediaPlayer.MediaPlayer.GoToPlaylistItem(Int32 playlistItemIndex)

Thanks,

Subhen


回答1:


After digging through Got the method which worked :

 custMediaElement.GoToPlaylistItemOnNextTick(currentPlayListItem);


来源:https://stackoverflow.com/questions/2873359/null-reference-exception-while-navigating-to-playlistitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!