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
How to detect the end of a video?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: How to detect the end of a video?
Check out "playerFinished" in the dictionary.
Simon
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 256
- Joined: Sun May 27, 2007 8:19 pm
Re: How to detect the end of a video?
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
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?
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
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?
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
Don