YTPlayerView Play video in full screen ipad - ios

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!

Related

Play Youtube Url In Webview without userControl in iOS

I want to play youtube url in UIWebview or MPMoviewviewcontroller.but the restriction is user should not control the playing video.could any one help ?
If you want finer control over youtube videos, theres a library (not written by me) called XCDYoutubeKit. Search for that and look at incorporating it into your app - theres a class in there that is based on MPMoviePlayerController, that allows the playing of youtube videos from their youtube id (I use it, its good). This also means you get a normal player, so you can pause, scrub through, etc.

How to play videos in uiwebview ios?

I'm building an article reading app for iphone.I'm parsing JSON content of article in uiwebview.
Some of the articles contains videos,But it does not display in the uiwebview.
JSON format for video is
<iframe src=\"\/\/www.youtube.com\/embed\/hdstrm\" height=\"360\" width=\"640\" allowfullscreen=\"\" frameborder=\"0\">
The uiwebview display empty space at the place of video frame
here is screen shot of uiwebview:
Displaying YouTube videos on iOS requires special treatment and is much less straight forward than you would expect (or hope). You can either display the entire YouTube page and let the user take it from there (or try to programmatically simulate a press on the play button), or you can "steal" the MP4 and play it using the media player.
The second option is better because it allows you to control the UI around the video and doesn't force you to display the entire YouTube page. However, it's important to stress that it requires quite a bit of work and is frowned upon by YouTube. In fact, they change the HTML structure of their pages every 2-3 months so that these mechanisms will break, and you won't be able to access the MP4 file directly without changing your code.
For more information on how to access the media file directly and play it, check out https://github.com/larcus94/LBYouTubeView

Youtube API - how to get video with custom controls for iOS

I'm working on an application that eventually will be uploaded to the App-Store so every solution you suggest has to be legit with licenses against Youtube and Apple.
I'm trying to create a custom video player for Youtube, which will have my own play/pause/stop and next/previous buttons. I've searched quite a lot for legit ways to make this and have not found the correct way yet.
The way I'm using it at the moment is with the Youtube embed player and the parameters:
controls = 0,
playsinline = 1,
autohide = 1,
showinfo = 0,
modestbranding = 1
With all that, I still have a play button on top of the video.
I've seen the iPhone application called "iTube" and they have their custom controls over youtube without the play button on top of the video. In addition, the looks and feels of the video over there doesn't suits me like the Youtube embed API. It just feels different.
Does anyone know how did they make that?
Well after some more research I've found that they probably used MPMoviePlayerViewController with custom controls.
It uses progressive download so I think they're using it with low quality over cellular networks to not violate Apple's terms.
If anyone thinks differently I would appreciate any response.
Thanks all!

Is there anyway to play a video inline in 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.

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