Latest 0.0.1
Homepage https://github.com/superm0/HCVimeoVideoExtractor
License MIT
Platforms ios 9.0
Authors

HCVimeoVideoExtractor is an easy to use Swift library for retrieving the Vimeo video details like title, thumbnail and mp4 URL which then can be used to play using AVPlayerView.

Requirements

HCVimeoVideoExtractor requires iOS 9.0 and Swift 3.2 and above

Installation

HCVimeoVideoExtractor is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'HCVimeoVideoExtractor'

and run pod install

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

Use the block based methods in HCVimeoVideoExtractor class to retrieve the Vimeo video details. Both methods will call a completion handler with two parameters. The first parameter is a HCVimeoVideo object which represents a Vimeo video. The second parameter is an Error object describing the network connection or internal processing error.

import HCVimeoVideoExtractor

Retrieve the Vimeo video details using URL

let url = URL(string: "https://vimeo.com/[video_id]")!
HCVimeoVideoExtractor.fetchVideoURLFrom(url: url, completion: { ( video:HCVimeoVideo?, error:Error?) -> Void in                
    if let err = error {                    
        print("Error = (err.localizedDescription)")                    
        return
    }

    guard let vid = video else {
        print("Invalid video object")
        return
    }

    print("Title = (vid.title), url = (vid.videoURL), thumbnail = (vid.thumbnailURL)")

    if let videoURL = vid.videoURL[.Quality1080p] {
        let player = AVPlayer(url: videoURL)
        let playerController = AVPlayerViewController()
        playerController.player = player
        self.present(playerController, animated: true) {
            player.play()
        }
    }                            
})

Retrieve the Vimeo video details using video ID

HCVimeoVideoExtractor.fetchVideoURLFrom(id: "video_id", completion: { ( video:HCVimeoVideo?, error:Error?) -> Void in
    if let err = error {
        print("Error = (err.localizedDescription)")
        return
    }

    guard let vid = video else {
        print("Invalid video object")
        return
    }

    print("Title = (vid.title), url = (vid.videoURL), thumbnail = (vid.thumbnailURL)")

    if let videoURL = vid.videoURL[.Quality1080p] {
        let player = AVPlayer(url: videoURL)
        let playerController = AVPlayerViewController()
        playerController.player = player
        self.present(playerController, animated: true) {
            player.play()
        }
    }
})

Author

Mo Cariaga, [email protected]

License

HCVimeoVideoExtractor is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "HCVimeoVideoExtractor",
    "version": "0.0.1",
    "summary": "HCVimeoVideoExtractor is an easy way to extract the Vimeo video details.",
    "description": "HCVimeoVideoExtractor is an easy way to extract the Vimeo video details like title, thumbnails and mp4 URL's which then can be used to play using AVPlayerView.",
    "homepage": "https://github.com/superm0/HCVimeoVideoExtractor",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mo Cariaga": "[email protected]"
    },
    "source": {
        "git": "https://github.com/superm0/HCVimeoVideoExtractor.git",
        "tag": "0.0.1"
    },
    "social_media_url": "https://twitter.com/sup3rm0",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "HCVimeoVideoExtractor/Classes/**/*"
}

Pin It on Pinterest

Share This