Closed mongkonsrisin closed 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
}
Do you have any example for playing DASH video ?
@mongkonsrisin See the streamURLs
property.
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)
}
}
Do you have Swift documenatation ?