Latest 0.2.3
Homepage https://github.com/toygar/youtube-parser
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

YoutubeSourceParserKit

==================
Build Status
License
Dependencies
Ready
StackOverflow
CocoaPods
Join the chat at https://gitter.im/mobileplayer/mobileplayer-ios

YouTube Video Link Parser for Swift

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
let testURL = NSURL(string: "https://www.youtube.com/watch?v=swZJwZeMesk")!
    Youtube.h264videosWithYoutubeURL(testURL) { (videoInfo, error) -> Void in
      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

class ViewController: UIViewController {

  let moviePlayer = MPMoviePlayerController()

  override func viewDidLoad() {
    super.viewDidLoad()
    moviePlayer.view.frame = view.frame
    view.addSubview(moviePlayer.view)
    moviePlayer.fullscreen = true
    let youtubeURL = NSURL(string: "https://www.youtube.com/watch?v=swZJwZeMesk")!
    playVideoWithYoutubeURL(youtubeURL)
  }

  func playVideoWithYoutubeURL(url: NSURL) {
    Youtube.h264videosWithYoutubeURL(url, completion: { (videoInfo, error) -> Void in
      if let
        videoURLString = videoInfo?["url"] as? String,
        videoTitle = videoInfo?["title"] as? String {
          self.moviePlayer.contentURL = NSURL(string: videoURLString)
      }
    })
  }
}

Latest podspec

{
    "name": "youtube-parser",
    "version": "0.2.3",
    "summary": "YouTube Video Link Parser for Swift",
    "homepage": "https://github.com/toygar/youtube-parser",
    "license": "MIT",
    "authors": {
        "Toygar Du00fcndaralp": "[email protected]"
    },
    "source": {
        "git": "https://github.com/toygar/youtube-parser.git",
        "tag": "0.2.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "youtube-parser/*.swift",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This