The only problem i'm having is that i'm unable to disable playing videos on full screen according to apple documentation this is enabled by default and needs to be set as follows:
webView.configuration.allowsInlineMediaPlayback = true
Which is based on my understanding how it's supposed to be. However this doesn't work and even after configuration right after you press play on video it opens up in native full screen player. I'm using WKWebView.
Apple's Documentation for this
I faced with this problem using video tag in web view.
I have three videos in the page, and all videos successively played full screen.
I solved this problem by
1.Check Inline Playback
2.Add playsinline attribute to video tag
<video src="your_videosrc" autoplay playsinline></video>
Glad someones help :)
Playing a video inline requires two prerequisites:
Setting the configuration
Providing a correctly formatted link
1. Setting the configuration
The configuration of the WKWebView has needs to be set while initialising. Modifying allowsInlineMediaPlayback at a later point will not work:
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
let webView = WKWebView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), configuration: configuration)
view.addSubview(webView)
2. Providing a correctly formatted link
In order for the web view to know that the video should start playing inline the appropriate URL parameter needs to be set.
For this you simply have to append ?playsinline=1.
Example:
webView.load(URLRequest(url: URL(string: "https://www.youtube.com/watch?v=OYbXaqQ3uuo?playsinline=1")!))
From Storyboad you can check/uncheck Inline playback to stop/allow full screen.
I'm having a similar issue, however it's a slight variation. We have a WkWebView that loads a mobile friendly web application. At various points there are links to videos which work great in that they do open the default iOS video player so the user can go full screen. That's all great. However we have a section where we have some podcasts. I'm trying to use the streaming provider's javascript player for these audio streams but when I press play the native iOS video player takes over. We don't want this because the provider's player has some features we need in it. I've tried adding the ?playsinline=1 but didn't have any affect on the playback. Is it possible to do this without affecting he video playback in the other areas of our app?
Related
I am trying to play a video from my UIWebView and play its audio in the background. This works fine, however when I lock my screen / close out of the view their is a slight delay in sound. The audio goes dead for a split second every time. Why is this happening? Is there a way to access avaudiosession of a UIWebview so I can get more information? Thank you.
Ive tried
adding all info.plist recommendations
enabling background mode
arbitrary loads = true
avaudiosession.shared().setactive = true
laying out views if needed
webView.mediaPlaybackRequiresUserAction = false
webView.allowsInlineMediaPlayback = true
webView.loadHTMLString(htmlString, baseURL: URL(string: "https://www.youtube.com"))
UIWebview is deprecated in swift 4 so for that you need to use WKWebview in same way. read user guide to use class of WKWebview.
I am using a light box type of player to open and play you tube videos. My people don't want the video link to be accessible or shared from within the player.
I.E they only want the video to play when the video loads in the player. So they don't want the share button visible and they don't want the YouTube icon that links directly to the video visible.
I can remove the share button and I can remove the YouTube icon but not at the same time.So there is always an easy way for the user to get the video url and share it etc...
I can also chose the videos to be private and that removes both. But then all of my users would need a google account which they dont.
It seems to me that Google wouldn't offer free use to its player without some type of reference to You Tube. Either with the share button or the You Tube icon that links to the video.
i have tried modifying the url parameters (embed?v=#v_ID#&rel=0&autohide=1&showinfo=0&wmode=transparent&modestbranding=1&controls=0") to no avail.
And I have tried using embed and watch to no avail..
Is there a way to do this?
You can append the following onto the end of the YouTube embed url, to remove the Watch on YouTube button from the playback controls which is accomplished by setting modestbranding to 1. The player controls are NOT removed. they are just auto0hidden by setting the parameter autohide to 1.
Try to change & to &
Here's a sample format to solves your issue:
My research tells me that there is now way to escape fullscreen video viewing in iOS browsers on iPhone or iTouch. It also seems there there is no way to modify the native controls that are displayed along with the video. Is the user in a total blackbox while viewing video in this case?
I'm trying to find someway for a user to indicate that they like a video as it is playing. Is there anything I can do that isn't a hack? If not is there any indication from Apple that they will ever be willing to change this? I'd rather not make an app out of this project.
You actually can play a video in line on an iOS browser, if this is what you are aiming for although there are restrictions - updated answer:
Play video inline in a browser on iOS
Safari on large screen iOS (iPad) should support inline video (I don't have iPAD hand to verify this still works...).
Safari on 'small screen' iOS (i.e. iPhone) will not support inline video as standard. There is at least one workaround which will allow it but this does bypass much of the native video playback performance gains so it may not meet your needs. It is a work in progress still as you will see from the link, but try the demo on an iPhone browser - you need to hit the small play button beside the video, rather than the one on top of the video at the time of writing:
https://github.com/newshorts/InlineVideo
Playing inline in a UIWebView on iOS
Take a look at this Apple Developer page:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/index.html#//apple_ref/doc/uid/TP40006950-CH3-SW31
In particular:
allowsInlineMediaPlayback
A Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller.
and:
Discussion
The default value on iPhone is NO.
In order for video to play inline, not only does this property need to be set on the view, but the video element in the HTML document must also include the webkit-playsinline attribute.
Using MPMoviePlayerController to stream an mp4 stored on a CDN, the file is actually an .m3u8
I've looked into this and there is no direct programmatic way of removing/disabling the bottom-right captions button unless the stream does not embed the subtitles in the first place.
I know for sure that the test video I'm working with does not contain subtitles which prompts the question: why is the captions button still visible then? Is there really no way of hiding it anyway? Tapping it will pause the video but not prompt the captions menu unlike streaming an .mpd file which does prompt the captions menu even without no available language option.
I'm doing the usual:
video = MPMoviePlayerController(contentURL: NSURL(string: url))
video.view.frame = UIScreen.mainScreen().bounds
video.controlStyle = MPMovieControlStyle.Fullscreen
For a locally stored mp4, the captions button won't appear which makes me think that the issue lies in either the m3u8 aspect of the file or that the CDN requires some additional setup like mentioned here: https://developer.apple.com/library/ios/qa/qa1801/_index.html
I open a video to play in the StageWebView:
var webView:StageWebView = new StageWebView();
var path:String = 'http://www.winterlife.com/files/apps/zhdk/test.mp4';
webView.stage = this.stage;
webView.viewPort = new Rectangle( x, y, width, height);
webView.loadURL(path);
This works fine, video starts playing.
Question 1: If I want to close the StageWebVideo, I touch "Done/Close". But nothing happens, except the video stops. (I want to close the video player and go back to my app.)
Question 2: How can I set the video to autoplay?
Question 3: When I start StageWebView, a white background appears for some short time. What is that, and how can I avoid it.
Thank you very much!
You have zero control over the video player in StageWebView by default. No events, no auto-play, nothing. What you want to do is simply not possible using that component.
You have two options:
Use a replacement ANE that mimics the functionality and gives you access to the things you want. UIWebView from Darkredz may be a possible substitute, though I haven't used it in 18 months, it hasn't been updated in 12, and it's not free.
Use StageVideo and build your own player around it. This is my preferred method. It still uses the native video player, but gives you great control over the video and a plethora of events to listen for. Plus you can design your own controls for it.
You can close the native video player by adding StageWebView in the popup container with a close button. Because, .mp4 is not supported flex video player in ios, instead of this we use native player to play the video.
While we use StageWebView it automatically take Native player in IOS. So we can add StageWebView in a popup container with a custom close button for dispose() StageWebView and close the popup container. By this method we can close our native video player in IOS.
StageWebView is always open in top of our application, when you click the link, the popup will open in top of the application, and stagewebview also will open in top of the application. You can modify the viewPort for adding close button.