Page 1 of 1

How to use VideoPlayer to play video on application window?

Posted: 22 Apr 2021, 11:06
by kunjiang
Hello, I'm a new student on BCI2000. I try to use VideoPlayer class to play a video on application window and successfully open video, but failed while playing video. The video duration is 1.05s. I create a new application module and add a piece of code,as follows:
void VideoDemoTask::StartRun()
{
VideoPlayer videoPlayer(mrDisplay);
videoPlayer.Open("D://project//video//M1//left.avi");
if (videoPlayer.IsOpen()) {
bciout << "open "<< endl;
}
int c = videoPlayer.FrameCount();
bciout << c << endl;
videoPlayer.SetFramePosition(0);
videoPlayer.Play();
if (videoPlayer.IsPlaying()) {
bciout << "PLAY " << endl;
}
}
In addition, I want to return a message as soon as the video is over. How do i do it?

Re: How to use VideoPlayer to play video on application window?

Posted: 04 May 2021, 08:57
by mellinger
Hi,

your VideoPlayer object is destroyed when execution leaves the StartRun() function. You need to create it on the heap (with "new").

Hope this helps,
Juergen