Why does WebRTC video freeze in iPhone Safari browser? - iphone

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.

Related

How to disable autoplay for YouTube video in WKWebView?

I have simple ViewController with WKWebView configured as follows:
webView.configuration.allowsInlineMediaPlayback = true
webView.configuration.mediaTypesRequiringUserActionForPlayback = .video
But right after loading a web page with YouTube video it starts to play automatically (and switching to full screen at the same time) without any user interaction which is required. How to disable autoplay?
I also had same problem,YouTube vide was playing in full screen
webview.configuration.allowsInlineMediaPlayback = true
programmatically setting allowsInlineMediaPlayback value didn't work for me
You can avoid video switching fullscreen by enable inline playback for WKWebview.
Check the webView storyboard property Interaction for Audio Playback. Yes, I know, this is a question about video, but setting the Video Playback checkbox doesn't work, at least not on a target iOS 13 simulator!
Probably just check everything in that section - inline playback, interaction for Audio, interaction for Video. That's what I'm doing, although my test shows only Audio is necessary. I suspect this is a WKWebView bug and Apple will fix it so that Video properly works instead of Audio :-)

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.

Playing video on iPad in native app and webview

I have a native iPad app that plays video. The app also uses a webview for some content and I would like to play a video in the webview as well.
Is it possible to play video natively as well as in a webview at the same time? I've read that only one video can play natively at the same time but does this apply if one video is native and the other is in a webview?
If a video is playing natively and a webview is loaded that includes a video, would initiating playback of the video in the webview automatically stop the native video or does there need to be communication from the webview to the native code to stop the video, and vice versa?
Thanks for your time.
I would say it isn't possible, in my experience when playing video in a webview the video is able to go fullscreen and when this happens it uses the same video player/controls that playing a video natively uses. I can't see how two videos would be able to use this player/controls at the same time.
You will also encounter memory issues, at least on the first iPad.

Accessing iPhone native video player that opens instead of HTML5 video

Annoyingly, when you have an HTML5 video on an HTML page, loaded inside an UIWebView, it opens the native player to play that video when you finally press the play button.
Is there a way to access that native player so I can either override the aspect ratio or hide the controls?
I tried checking all of the views that were added to my UIWebView, but that didn't get me anywhere.
Cheers
Maybe you could intercept the click on video inside your UIWebView and starts the native player pointing it to the video url.
In this way you have full control on the video player.

Closing iPhone Video Player using Javascript

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