0xced / XCDYouTubeKit

YouTube video player for iOS, tvOS and macOS
MIT License
2.92k stars 626 forks source link

Swift documentation ? #402

Closed mongkonsrisin closed 5 years ago

mongkonsrisin commented 5 years ago

Do you have Swift documenatation ?

SoneeJohn commented 5 years ago

The library is very straightforward, you will most likely be interacting with XCDYouTubeClient and looking at the properties on XCDYouTubeVideo. You can always use the generate interface function in Xcode to view the headers in Swift.

Here is an example in Swift that should get you started:


XCDYouTubeClient.default().getVideoWithIdentifier("tG7vx7-3sl0") { (video, error) in
    guard video != nil else {
    // Handle error
    return
    }
    //Do something with video
}
mongkonsrisin commented 5 years ago

Do you have any example for playing DASH video ?

SoneeJohn commented 5 years ago

@mongkonsrisin See the streamURLs property.

heestand-xyz commented 4 years ago
import AVKit
import XCDYouTubeKit
func playYouTubeVideoInFullscreen(id youTubeID: String, in viewController: UIViewController) {

    let playerViewController: AVPlayerViewController = AVPlayerViewController()
    viewController.present(playerViewController, animated: true, completion: nil)

    XCDYouTubeClient.default().getVideoWithIdentifier(youTubeID) { (video, error) in

        guard let video: XCDYouTubeVideo = video else {
            playerViewController.dismiss(animated: true, completion: nil)
            return
        }

        playerViewController.player = AVPlayer(url: video.streamURL)

    }

}