Home > Archive (Community help, from old helpdesk) > MediaPlayer OnStop event Problem.

MediaPlayer OnStop event Problem.

Avatar image
Aug 23, 2015
Archive Agent wrote
because I need to continue play some movie when some movie play finish. so I add something in OnStop event when window init:
Player.OnStop -= Player_OnStop;
Player.OnStop += Player_OnStop;

private void Player_OnStop(object sender, StopEventArgs e)
{

PlayNextSong();// thre is no stop. just clear playlist and add new one.
}

but the problem is First time it's ok. when it's play finish , it's will play next movies. but . second time. when is stop and play next movie....and into the OnStop event again.
I don't know why.... why second time the OnStop gonna execute twice
.

qakmak on May 28, 2013 10:11
Completed
0
Vote
Reply
7 Answers
Aug 23, 2015
Archive Agent agent wrote
qakmak

and my some problem not finish, don't forge to check the problem you Mark as complete.

on May 28, 2013 10:29
Aug 23, 2015
Archive Agent agent wrote
Roman Minyaylov

Use Playlist feature...

on May 28, 2013 14:26
Aug 23, 2015
Archive Agent agent wrote
qakmak

I can't . you playlist so easy, and it's not support mvvm model. I'm use my own playlist
ObservableCollection<MediaModel>. and every time I play next movies. I'm clear sdk playlist and add just 1 movies path to playlist from my owe play list

and even I'm use your playlist. you need give me playNextFile method. and play previous file. if you add this, you need add more handle evertime current media is change the sound , effect , mute all not change.

so, now I just need Player_OnStop event not has that problem.

on May 28, 2013 14:48
Aug 23, 2015
Archive Agent agent wrote
qakmak

and if manually play next movies. not have this problem.
because I use this like that

if need play next movies. I set the status:

IsAlreadyStop = true;
Player.Stop();
PlayNextMovies();

and this is my OnStop event method

private void Player_OnStop(object sender, StopEventArgs e)
{
// if now is auto play finish
if (!IsAlreadyStop)
{
PlayNextMovies();
}
//that is user manual stop. ignore
else
{
IsAlreadyStop = false;
}
}

on May 28, 2013 15:18
Aug 23, 2015
Archive Agent agent wrote
qakmak

you can add my code in your code test it. manual play next movies is not any problem.
but auto play finish have that problem. I mean auto play finish second time the OnStop gonna execute twice

on May 28, 2013 15:20
Aug 23, 2015
Archive Agent agent wrote
Roman Minyaylov

OnStop event called from not the main thread. File playback must be started from main thread. So, use invoke to run it from correct thread.

on May 28, 2013 16:15
Aug 23, 2015
Archive Agent agent wrote
qakmak

you're right. this problem has been resolved. thanks for helping.

on May 28, 2013 18:10