Is there anyway to play a video inline in iOS? - ios

I've tried tens of different ways to play a video from YouTube or a server and not have it go into fullscreen. I know it's possible because the YouTube app allows for this to happen but can't seem to figure out how to do it. Please advise!

Check out this answer:
Can I play a youtube video in a UIWebView inline (not fullscreen)?
This solution is iOS 6 & 7 compatible, it involves setting UIWebView's allowsInlinePlayback and setting YouTube's iFrame webkit-playsinline value.

Related

UIWebView to play Html 5 video without going to Video Player of iOS

I want to use video player technique used in my website. I use html 5 videos in website and send normal URL to app so that they can be played using the native MPMoviePlayerController inside the app. Now I have requirements where I want to use the same technique as web inside the app as UIWebView. When I request the link to load, it opens up the default player view of iOS, which I want to avoid.
Can this be possible?
No, this is not possible. Not in the Safari browser. Videos will always be played by the native player. Trust me, I've spent a lot of time on this.
If you build a Phonegap app, it is possible by what is mentioned here:
HTML5 inline video on iPhone vs iPad/Browser
Basically:
HTML
<video id="player" width="480" height="320" webkit-playsinline>
Obj-C
webview.allowsInlineMediaPlayback = YES;

Unable to play youtube video on iOS

I am using YTPlayerView to play a YouTube video on iOS.
However, I get the error message seen below for some videos and am unable to play them on an iPhone.
This video contains content from Panorama. It is restricted from playback on certain sites
What can be the possible issue ?
I got the answer. All i had to do is to enable Allow embedding in Distribution Option in Advance settings of video.

YTPlayerView Play video in full screen ipad

I am using "YTPlayerView" to play video in iOS. When I am using this in iPhone it automatically play video in full screen but when I am using same thing in the iPad it does not switch to full screen. I also tried the below parameters but no success.
NSDictionary *playerVars = #{ #"playsinline" : #0 };
[self.playerView loadWithVideoId:videoIDURL playerVars:playerVars];
We have developed a very video intensive app for both iPhone and iPad in the past, and actually had the opposite problem - we wanted to use the YTPlayerView for displaying videos inline (non-fullscreen) on both devices, but weren't able to get it done on the iPhone. We ended up using XCDYouTubeVideoPlayerViewController, which seemed to have resolved most of our issues. This is not really the recommended way to approach this, since it pretty much breaks YouTube's terms of use (it parses the html page, finds the .mp4 url, and plays it in MPMoviePlayer, which gives all all of the flexibility you need for full screen, loading times and other notifications.
Throughout the process of trying to find a way to work with YTPlayerView, I contacted engineers form Google who work on the YouTube helper framework, and they recommended to work directly with the iframe player API, which lets you customize the controls and receive events about the video. This means you'll have to use your own web view instead of the YouTube helper. The communication between the JavaScript and the Objective-C parts can be tricky (and that's what the helper library actually tries to save from the developer), but it will give you more flexibility.
This can also help with working with UIWebView to display YouTube videos: Playing YouTube Videos in a WebView Inline.
I know it's not exactly what you asked, but I hope it can help lead you in the right direction. I've had a lot of issues working with YouTube videos on iOS, so I know how frustrating it can be. Good Luck!

Playing Vimeo Videos with Custom Video Player in iOS

I have to play Vimeo videos in my iOS application using a video player. I need to log events like play, pause, seek etc. Its not possible to play using MPMoviePlayerController or AVPlayer as Vimeo videos have flash content. I am able to play using UIWebView. But, it is showing default Vimeo player controls. I need to have my own controls to play, pause etc as I need to log those events.
I have tried for lot of solutions. Nothing worked. If anyone knows how to play Vimeo videos using custom player. Please Let me know.
I am able to find out solution for this problem. I have used YTVimeoExtractor present here.
Its README.md file says following :
YTVimeoExtractor helps you get mp4 urls which can be use in iOS's native player. You can even choose between mobile, standard and high definition quality.
YTVimeoExtractor doesn't use UIWebView which makes it fast and clean.
I have used MKMoivePlayerViewController and its notifications - MPMoviePlayerPlaybackStateDidChangeNotification and ˚ notifications to get stop, pause events.
The only official way to use a player besides the Vimeo player to play Vimeo videos is to use third-party player urls provided to PRO members: https://vimeo.com/s/adg

How to play a youtube video list in ios natively

I need to play youtube video lists in an iphone app. I did a quick research but still could not find the answer. Most of the answers out there are about playing a single youtube video in iOS by embedding a youtube url in a HTML page and load it in a UIWebview. But it doesn't seem to be the way for playing a list. But I guess it's possible because there are apps that can do that.
Update: I managed to play a list in a UIWebView with iframe method, but it not what i set out to do. I need to play the video not in a full screen mode. Is there anyway to do so?
Thanks
Using UIWebView's internal MPMoviePlayerController, it may be possible to load the videos one by one by storing their URLs in an array and incrementing the array's object position when the finish event is sent internally by the iFrame's javascript. iFrame methods are documented here, and a way to inject a webview with javascript is shown here.
As for non-inline video playing (only fullscreen), set allowsInlineMediaPlayback to NO on the UIWebView.

Resources