I try to play 2 videos in same axmediaplayer. my theory is this: the main movie will play until the timer event fire. then then new movie will play and the last movie position will save and after finishing the second movie, the last one will continue from last movie position.
but after finishing the second movie, my axmediplayer wont work and wont continue the first movie...
I searched in net and someones said that happend because of Calling URL from an event handler. but I dont know how to fix it and how to set it out of handler...
private void timerTeserInterval_Tick(object sender, EventArgs e)
{
if (this.MoviePlayerCanPlayTeaser && playerMode != PlayerMode.TeaserMode && axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
MoviePlayerCurrentPossition = Convert.ToInt32(axWindowsMediaPlayer.Ctlcontrols.currentPosition);
LastMovieName = MoviePathFile;
axWindowsMediaPlayer.Ctlcontrols.pause();
}
}
private void PlayMovie()
{
if (MovieNameList == null || MovieNameList.Count == 0)
return;
if (playerMode == PlayerMode.MovieMode && MoviePlayerCurrentPossition == 0)
{
if (MovieNameListIndex < MovieNameList.Count)
{
MoviePathFile = MovieFolder + "\\" + MovieNameList[MovieNameListIndex];
MovieNameListIndex++;
}
else
{
MovieNameListIndex = 0;
MoviePathFile = MovieFolder + "\\" + MovieNameList[MovieNameListIndex];
MovieNameListIndex++;
}
try
{
axWindowsMediaPlayer.URL = MoviePathFile;
if (axWindowsMediaPlayer.URL != "" && axWindowsMediaPlayer.URL != null)
{
axWindowsMediaPlayer.Ctlcontrols.play();
playerMode = PlayerMode.MovieMode;
}
}
catch { }
}
else if (MoviePlayerCurrentPossition != 0)
{
try
{
axWindowsMediaPlayer.URL = LastMovieName;
axWindowsMediaPlayer.Ctlcontrols.currentPosition = MoviePlayerCurrentPossition;
if (axWindowsMediaPlayer.URL != "" && axWindowsMediaPlayer.URL != null)
{
axWindowsMediaPlayer.Ctlcontrols.play();
playerMode = PlayerMode.MovieMode;
}
MoviePlayerCurrentPossition = 0;
}
catch { }
}
}
private void PlayTeaser()
{
if (this.MoviePlayerCanPlayTeaser)
{
if (TeaserNameList == null || TeaserNameList.Count == 0)
return;
if (TeaserNameListIndex < TeaserNameList.Count)
{
TeaserPathFile = TeaserFolder + "\\" + TeaserNameList[TeaserNameListIndex];
TeaserNameListIndex++;
}
else
{
TeaserNameListIndex = 0;
TeaserPathFile = TeaserFolder + "\\" + TeaserNameList[TeaserNameListIndex];
TeaserNameListIndex++;
}
try
{
axWindowsMediaPlayer.URL = TeaserPathFile;
if (axWindowsMediaPlayer.URL != "" && axWindowsMediaPlayer.URL != null)
{
playerMode = PlayerMode.TeaserMode;
axWindowsMediaPlayer.Ctlcontrols.play();
}
}
catch { }
}
}
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
{
playerMode = PlayerMode.MovieMode;
PlayMovie();
}
else if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPaused)
{
playerMode = MoviePlayer.PlayerMode.TeaserMode;
PlayTeaser();
}
}