Page 1 of 1

How to detect the end of a video?

Posted: Thu May 09, 2013 10:37 am
by grovecat
I create a native video player in code and give it a path to a video on the camera roll (using the mergAV external). Then via a transparent button over the screen I can either use the button to toggle pause and play, or set it to stop the video. When I stop it this way, my code deletes the player and returns to another card. So far so good.

The problem is that when the video ends naturally it just hangs on the last image and I want it do the same as when it is stopped as above. And I can't work out how to accomplish that small task. I thought I may be able to obtain the duration from a mobileControlGet property, and use a Send message based on that time, but both playableDuration and endTime return zero.

So how can I determine when a video ends naturally?

TIA
Don

Re: How to detect the end of a video?

Posted: Thu May 09, 2013 1:42 pm
by Simon
Check out "playerFinished" in the dictionary.

Simon

Re: How to detect the end of a video?

Posted: Thu May 09, 2013 5:56 pm
by Martin Koob
DId you try the message AVPlayerItemDidPlayToEndTimeNotification?

put a handler for this in the control that you used to create the AVPlayer with a parameter for the Player pointer.

Martin

Re: How to detect the end of a video?

Posted: Fri May 10, 2013 1:33 am
by grovecat
Thanks guys

The playerFinished message does the job nicely.

I can't use the AVPlayerItemDidPlayToEndTimeNotification, which relates the mergAV player. I'm only using mergAV to get the path to the video, which I then pass to the native iOS player.

Cheers
Don

Re: How to detect the end of a video?

Posted: Fri May 10, 2013 4:56 am
by grovecat
Perhaps I should explain why I use mergAV to pick the video and then use a native player rather than the mergAVPlayer. The reason is that in this case I am picking a video from the camera roll, and that path can't be played by the mergAVPlayer but the native iOS player can handle it.

Don