Stop video after exiting fullscreen on Mobile Safari - ios

Hey Guys,
I've got a thumbnail on a webpage that when clicked, plays a video in fullscreen using the webkitEnterFullscreen() method.
But I need the video to stop playing once the users touches the "Done" button and leaves fullscreen mode.
Is there an event that fires once the the user has exited fullscreen?
Thanks,
Drew

I had an email from an Apple developer which answered this question for me.
The two events are webkitbeginfullscreen and webkitendfullscreen. This piece of sample code is really useful for seeing the order that events fire (it logs a message to the page whenever an event is emitted), and includes these two events:
http://developer.apple.com/library/safari/#samplecode/HTML5VideoEventFlow/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40010085-Intro-DontLinkElementID_2

Related

iOS Safari + Vimeo iframe, detect "Done" button press in native player

I have a Vimeo iframe embed on a mobile site, and am trying to figure out how to detect when the user presses the "Done" button in the native iOS Safari video player.
I know this is possible with the "webkitendfullscreen" event if you are embedding with a video tag directly (as described here):
$('video').bind('webkitendfullscreen', function()
{
console.log('on webkit close');
});
However, the video object is not accessible in the case of a foreign iframe embed.
I have not, so far, been able to find a good way to get this to happen, after quite a lot of keyboard-head-banging. I really hope Vimeo adds a way to do this in the future. The only thing I have found is in their new JS API, there is an event fired when the video has ended, and you can latch on to that and do something if they watch the video all the way to the end. You can also detect when the user pauses the video and do something after a "reasonable" time-frame, depending on what you are trying to do.
My hope was that I would be able to close the corresponding modal window whenever someone closes out of a video, but that was really not a possibility.
you can use the leavepictureinpicture event
myPlayer.on("leavepictureinpicture", () => console.log("leave pip triggered"));
https://github.com/vimeo/player.js/blob/master/README.md#leavepictureinpicture

Strange behaviour in iOS Today Widget with AVPlayer

I'm really getting crazy on this, so I'd ask for some help.
I'm coding a little widget that presents two UIButton the user can tap, once pressed the widget adds a notification to the app, if the button is pressed again the notification will be deleted.
Initially I added a sound to the touch of the button and worked ok with AVPlayer, then I decided to use the haptic engine to give feedback to the user so I deleted the AVPlayer call to stop the sound: guess what? the button continues to play the sound! I've commented the code I used to play the sound, how can it still play the sound?.
The strange thing is that one button has got this strange behaviour, while the other just works fine (only haptic engine), it sounds like a bug but I'm a rookie and it should be my fault somewhere.
Any idea?

iOS: App Home Button Shortcut

Having trouble finding the API for the home screen shortcuts when the home button is clicked. My app plays audio and I want those similar shortcuts to pop up like the do for the iPod to give me the option to stop playback.
Can someone just point me to the reference?
This is a good place to start:
Remote Control Events
From the Apple documentation:
Test that your app is properly receiving and handling remote control
events with the Now Playing Controls. These controls are available on
recent iOS devices that are running iOS 4.0 or later. To access these
controls, press the Home button twice, then flick right along the
bottom of the screen until you find the audio playback controls. These
controls send remote control events to the app that is currently or
was most recently playing audio. The icon to the right of the playback
controls represents the app that is currently receiving the remote
control events.

How to figure out when a HTML5 video player enters the full screen mode on iOS / iPads?

The HTML5 <video> tag offers the user a button to toggle on and off the fullscreen mode on Safari for mobile devices (iOS).
I would like to capture and handle this user action but it doesn't seem to raise an event when the button is pressed and the player enters the full screen mode.
Here is the link to the Safari API for the HTMLVideoElement class:
https://developer.apple.com/documentation/webkitjs/htmlvideoelement
We can easily find out when the video is paused of played in Javascript, like this:
function onload()
{
var player = document.getElementsByTagName("video")[0];
player.addEventListener('play',videoPlayHandler,false);
player.addEventListener('pause',videoPauseHandler,false);
}
However they don't seem to have any events for when the video enters the full screen mode.
We can force the video into fullscreen mode in response to user action by calling the webkitEnterFullscreen(), but that doesn't help me. I need to know when the user taps on the fullscreen button.
Hiding the controls and replacing them by my own custom controls sounds like a really long winded solution.
Another option I can think of is to set a timing event, constantly checking for the webkitDisplayingFullscreen property, but that feels like a bad thing to do in terms of memory management.
Can anyone suggest a better solution?
After much faffing around a friend finally pointed me in the right direction.
The events I was looking for are: webkitbeginfullscreen and webkitendfullscreen
var player = document.getElementsByTagName("video")[0];
player.addEventListener('webkitbeginfullscreen', onVideoBeginsFullScreen, false);
player.addEventListener('webkitendfullscreen', onVideoEndsFullScreen, false);
With that I can safely capture when the user clicks over the fullscreen button on Safari for the iPads. Interestingly the same events don't seem to work for Safari on the iMac (tested on version 5.1.2).
Thanks Apple for their inconsistency and hours of wasted time.

application is crashing while user exits from fullscreen mode in mpmovieplayer

hi folks we do have a video file in our application,every thing is going fine except one,i.e the application crashes when user exits from fullscreen mode while the movie is playing and also when we pause the movie in fullscreen mode and minimize it,the video starts from the beginning i tried searching whether there is any notification available to notify but of no use plz help me out.thx in advance.
atlast after studying a lot about mpmovieplayer class refernece i could find the answer for my question which i had posted yesterday.The reason for that was i was not able to provide all the available notifications i need, now i had mentioned each and every notification for entering into full screen,exit the fullscfreen and also playbackfinished now its working fine.The only problem is when i press the toggle screen it maximizes perfectly and plays from the current playbacktime but that not the case when i minimize the screen the video plays from the begining.

Resources