Open iframe video in fullscreen programmatically - ios

I open youtube video using iframe in webview. It shows default control buttons for video including fullscreen button. How can I call function of fullscreen button by myself? For example, I want go to fullscreen on landscape, but videos open in fullscreen only by tap on fullscreen button or while first loading. I need go to fullscreen while playing video.

Hope you are using YTPlayer for YouTube Videos.
If not you can find the player here - GithubLink
For YTPlayer, there's a parameter playsinline.
To always play fullscreen, you need to set the playsinline property to 0. Something like:
let playerVars = [
"playsinline" : 0
]
player.loadWithVideo(id:movieURL, playerVars:playerVars)

I have found function. There is webkitEnterFullScreen in webkit's video tag: https://developer.apple.com/documentation/webkitjs/htmlvideoelement
So all I need is to get video and execute function through javascript:
playerView.webView?.evaluateJavaScript("document.getElementById('player').contentDocument.getElementsByClassName('video-stream')[0].webkitEnterFullScreen()") { object, error in
print(error)
}

Related

Remove the AVPlayerViewController from the wkwebview after it plays an inline video

So I have wkwebview which displays an html text that includes video urls as well. On tapping the video thumbnail, the wkwebview launches the AVPlayer to play the video just fine. But after viewing the video, I need to remove the player so that other information on the wkWebview is visible.But the player makes the wkwebview go blank. I am attaching the screenshots
1. normal article with text and video thumbnail(calendar icon)
2. Video being played normally
3. After video being played, the rest of the wkwebview going blank.
I want to get back to state 1 from 3.

iOS does not show/play video in UIWebView iframe

I use UIWebView with the:
var html:String = "<iframe src='http://46.101.234.111/trailers/suicide_squads_1' width='100%' height='200px' scrolling='no' frameborder='no'></iframe>"
cell.trailerView.loadHTMLString(html, baseURL: nil)
but it doesn't show/play the video on start. It just show play icon on white row and when I press on it - nothing happens.
iframe works, I checked it. What is the problem and how can I fix it?
Videos on the iPhone will not auto play from websites. Also make sure the video is in a format that can be played on an iPhone.

Show airplay/route button on default video player in iOS

Why is it so difficult to show the airplay button in the default video player? Why isn't there a simple on/off switch? My app has a webview in place and videos that open through the webview open the default video player with no airplay button.
I tried using MPVolumeView and got the button to display in a view, but I cannot figure out how to show it in the place it normally should show, see image: http://i.stack.imgur.com/0xdoo.jpg

how to play video with native player instead of web player for a <video> tag?

We have a UIWebView that load html page including video tag. When the user tap the video element, a fullscreen movie player is presented.
As there is some logic in the web page that handle events and need to stop and close the movie player. Is there any API to do so (stop the web movie player and exit fullscreen)?
Any one know how to do this?
Further more, even we want to detect tapping on the video element, then we'll have to provide our own custom player, instead of the system web player. Any way to do it?
Thank you!
This might be helping, if you want to controll the HTML5 video with js: http://www.w3.org/2010/05/video/mediaevents.html
I am not shure if - on a mobile device - javascript will be running while the video is in fullscreen mode.

How can I force a video played in a UIWebView to be full screen on an iPad?

I'm playing a YouTube video using a UIWebView, like so:
self.webView.mediaPlaybackRequiresUserAction = NO;
self.webView.allowsInlineMediaPlayback = NO;
[self.webView loadHTMLString:videoEmbedCode baseURL:nil];
I want to force the video to play in full screen without the user tapping the button at the bottom right. This works fine on an iPhone (tap the player to play and it automatically enters full screen), but doesn't work on an iPad (the normal inline player is shown).
I assumed that setting allowsInlineMediaPlayback to NO would do the trick, but apparently not.
Is there a way to force HTML5 videos to play in full screen on an iPad?
If you are trying to play a youtube video in fullscreen directly, then Use a webview of size fullScreen and then handle its rotation accordingly and change the player size of Rotation too. If you need more help then i can help you with the code too for how to change the player size on rotation too.

Resources