Skip to content

Repository files navigation

YoutubeSourceParserKit

================== Build StatusLicenseDependenciesReadyStackOverflowCocoaPodsJoin the chat at https://gitter.im/mobileplayer/mobileplayer-ios

YouTube Video Link Parser for Swift. Heavily inspried from hellozimi's repo HCYoutubeParser

##Introduction

Requires iOS 8 or later and Xcode 7.0+
Swift support uses dynamic frameworks and is therefore only supported on iOS > 8.

##Installation

To install via CocoaPods add this line to your Podfile.

use_frameworks!

and

pod 'YoutubeSourceParserKit'

Then, run the following command:

$ pod install

##Usage

import YoutubeSourceParserKit
lettestURL=NSURL(string:"https://www.youtube.com/watch?v=swZJwZeMesk")!
Youtube.h264videosWithYoutubeURL(testURL){(videoInfo, error)->Voidin
if let videoURLString =videoInfo?["url"]as?String,
videoTitle =videoInfo?["title"]as?String{print("\(videoTitle)")print("\(videoURLString)")}}
videoInfo output:
{
"title": "[Video Title]",
"isStream": 0,
"quality": "hd720",
"itag": 22,
"fallback_host": "tc.v20.cache2.googlevideo.com",
"url": "http://[Source URL]"
}

##MPMoviePlayerController Usage

alt tag

import UIKit
import YoutubeSourceParserKit
import MediaPlayer
classViewController:UIViewController{letmoviePlayer=MPMoviePlayerController()overridefunc viewDidLoad(){
super.viewDidLoad()
moviePlayer.view.frame = view.frame
view.addSubview(moviePlayer.view)
moviePlayer.fullscreen =trueletyoutubeURL=NSURL(string:"https://www.youtube.com/watch?v=swZJwZeMesk")!
playVideoWithYoutubeURL(youtubeURL)}func playVideoWithYoutubeURL(url:NSURL){Youtube.h264videosWithYoutubeURL(url, completion:{(videoInfo, error)->Voidin
if let
videoURLString =videoInfo?["url"]as?String,
videoTitle =videoInfo?["title"]as?String{self.moviePlayer.contentURL =NSURL(string: videoURLString)}})}}

Warning: This repo is for educational purposes. This is not approved by the ToC of YouTube. Use at own risk.

About

YouTube link parser for swift

Resources

Stars

691 stars

Watchers

35 watching

Forks

Releases

Packages

Contributors

Languages