Closing iPhone Video Player using Javascript - iphone

I have a web page with several html5 tags, offering users a number of posters/thumbnails for videos they can choose to play. When a user touches one of the them the iPhone video player opens and the video plays. I want to be able to automatically close the video player after the video has finished and return the user to the thumbnails.
I have set the event listener for the "ended" event and I can detect that the video has finished, but I can't figure out how to close the video player and return to the thumbnails. It just waits for the user to touch the "done" button. Is there any way of doing this in Javascript??

jQuery -
$('video').get(0).webkitExitFullscreen();
Uncertain what iOS version this was supported. See The correct method is webkitExitFullscreen. See https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode for full support

Related

Why does WebRTC video freeze in iPhone Safari browser?

I am using Ant Media Server for ultra-low latency WebRTC streaming. But video stream is freezing when I play it from the iPhone Safari browser. How can I solve this?
Yeah it's about safari autoplay scenario in WebRTC. In documentation, It says that
However, for a one-way video conferencing scenario, such as a webinar, the user does not give explicit permission to the camera. Without a user gesture to indicate playback, the video cannot start. Add a play button to your media controls for one-way WebRTC experiences, so the user can start the video.
Another place in documentation also says that
By default, autoplay executes only if the video doesn’t contain an audio track, or if the video element includes the muted attribute.
So solution is that, you either play content explicitly or you can mute the player and let the safari autoplay work for you. For some cases, it does not even auto play if it's muted so that you need some failover scenario again.
From our experience, if it freezes in the first frame with unmuted content, just click the play button on the screen as shown below works every time.
Browser will autoplay VIDEO element only if muted.
Solution is to add a Tap for Audio and start it muted or a Tap to Play button if important to start with sound. As in this HTML5 Videocall App.
use
setTimeOut(()=>{
video.play();
});
The Safari browser wants the user intervention to start/stop video stream. The above code snippet mimics that behaviour and starts the video stream in the video element.
If you are drawing the video element on canvas then you have to set the opacity=0.001 and width and height of the video element to 1px at least.

How to get AirPlay from UIWebView to continue playback when app is backgrounded *without* setting AVAudioSession category to Playback?

I've been attempting to make this work for quite a while now:
My app has the potential to play videos of Youtube from within UIWebView. The user could want to use AirPlay for this. When AirPlay is on, the device could go to sleep and normally video stops playing moments after that happens. As advised in other posts, I set the AVAudioSession category to the Playback one and it works - AirPlay continues even when the device display goes to sleep.
However, this has a side-effect; if the user has activated the app while music playback is on in the background, setting the app's audio session category to Playback causes the playing music to stop and this is definitely annoying.
Ideally, I want to set the AVAudioSession category when playback of Video starts, not when my App is activated - but I've not seen any central or UIWebview notification / delegate method to determine this.
I've got a hackish workaround for iPhone where the UIWebview hosted video player always loads full screen modal and thus can be determined. But my app is Universal and on iPad the video starts inline; I can't figure out a way to know when Video playback is going to happen. This is exactly the point when the audio category should be switched to Playback - it will actually help users who want background music playing only until video starts up.
I don't want to fool around with adding Javascript events on to Video tags inside the UIWebView - that seems too fragile to me.
Is it possible to observe any AVFoundation notifications that trigger for the UIWebView video playback? Or anyone know of any other way to determine if video playback will start / has started?

Tips on using webview to play an embedded Flash movie

I've tried (without success) to get a video to play within a webview. I can see the video thumbnail with the default play button overlaying the video.
When I click the play button - the entire video hi-lights in transparent yellowish/orange. Clicking play again causes the Play button to blink. The thumbnail always remains, but never plays. I can even see the timeline below the video with the play-head, etc. I can never touch the video controls, because every click treats the entire video like one big button - and hi-lights like mentioned above.
They are numerous videos to be played and they are not at YouTube, so launching the YT player with an intent isn't desired.
I'm using SDK 8 (2.2), runing on a 2.3.6 device, and Have the latest Flash Player 11.xxxxx installed.
Any suggestions?
Took another approach in the app.

Adding a YouTube video to my application

I am trying to embed a YouTube video in my application, and I am going through this tutorial as a start. I get the red screen when I run it on the stimulator, so I presume everything went well.
Now when the user taps on the screen while the video is playing I need a toolbar to appear, with a slider showing the length of the video (and the user could slide to his/her desired time on the video).
I need to know if this feature comes by default when you embed the YoutTube video, or do i have to code it? If i have to code it how should i do it? Any sample codes or tutorial?
The only way to show a YouTube video in an iOS app is by having it inside a UIWebView (that is what the tutorial walks you through). Once the user taps the "play" button, the video should go full screen and automatically present the standard video controls that you see when you play videos on iOS.
Youtube provides the HTML code for embedding videos in web pages. This HTML code will also produce a video when embedded in a UIWebView. While the video is playing, all of the standard Youtube video controls (Play, Pause, Time Slider) should also show up in the UIWebView.

Close of video player in iphone

Am using html5 to play video on iphone. Is there is way to know when video player is close because i want to call function after clicking on done button. I can't use 'ended' this event occurs only after completion of video. I appreciate your suggesions.