Tuesday 12 August 2014

YouTube Player for iOS

The older way of embedding youtube videos into iOS Applications was adding the video link into a UIWebView and loading it. Now google came up with a Helper library , by which we can embed youtube videos into UIView(internally UIWebView on top of UIView) and can play more easily.

The main advantage of this Helper library is , we will get more options and control over the video. By which we can do  Play, Pause, Stop and Video Skipping.

Steps for integrating YouTubeHelper library into existing Xcode Projects

1. Download the Library Source from GitHub.

2. Add the following files "YTPlayerView.h",  "YTPlayerView.m", and the "Assets" from library folder into your application project.

3. Create an IBOutlet property with "YTPlayerView" and map the corresponding "UIView" component in the XIB file. "YTPlayerView" is a subclass of "UIView", you need to change the class type of "UIView" component into "YTPlayerView" in the identity inspector.

4. Please refer the direct link for information.
https://developers.google.com/youtube/v3/guides/ios_youtube_helper#installation_manual

5. While running the App in iOS 7, incase if you encountered an issue as like the following
 "Received error rendering template: Error Domain=NSCocoaErrorDomain Code=258 "The operation couldn’t be completed. (Cocoa error 258.)"" , refer the following link.

http://stackoverflow.com/questions/23751817/try-to-play-you-tube-video-with-ytplayer-third-partry-libraray-in-ios

After Successfully integrating , use the following methods to load and play the youtube url.

(a)load video with youtube id.

(b)play a video after loading it.

(c)pause and stop the video

(d)Doings with delegate methods, the following "YTPlayerView" delegate methods can be used for having more control on top of YouTube player.

(e)getting the quality levels.

I have just embedded a youtube video into my "viewcontroller". The "UIView" size I have given is (640, 320) this is the size for a medium quality video.



 
Reference:-

Please refer the following google developer link for more info.
https://developers.google.com/youtube/v3/guides/ios_youtube_helper#installation_manual

1 comment:

  1. Hello, after reading this amazing piece of writing i am also delighted to share my knowledge here with friends.

    ReplyDelete