我正在null
上寻找播放{i}原生播放器上的class MyEntity
{
/**
* @Assert\Email()
* @CustomAssert\EmailDomain(domains = {"yahoo.com", "gmail.com"})
*/
protected $email;
视频,就像XCDYouTubeKit一样,XCDYouTubeKit仅用于目标-c我找不到任何swift pod都是这样的,所有我发现他们嵌入了iframe视频和youtube徽标,这将允许用户点击它并在整页打开时错过页面。
如何在swift
原生Youtube
播放器上播放YouTube视频?没有html嵌入!
答案 0 :(得分:5)
虽然XCDYouTubeKit是用Objective-C编写的,但它与Swift集成得很好。以下是一些与Swift 3一起使用的示例代码:
struct YouTubeVideoQuality {
static let hd720 = NSNumber(value: XCDYouTubeVideoQuality.HD720.rawValue)
static let medium360 = NSNumber(value: XCDYouTubeVideoQuality.medium360.rawValue)
static let small240 = NSNumber(value: XCDYouTubeVideoQuality.small240.rawValue)
}
func playVideo(videoIdentifier: String?) {
let playerViewController = AVPlayerViewController()
self.present(playerViewController, animated: true, completion: nil)
XCDYouTubeClient.default().getVideoWithIdentifier(videoIdentifier) { [weak playerViewController] (video: XCDYouTubeVideo?, error: Error?) in
if let streamURLs = video?.streamURLs, let streamURL = (streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming] ?? streamURLs[YouTubeVideoQuality.hd720] ?? streamURLs[YouTubeVideoQuality.medium360] ?? streamURLs[YouTubeVideoQuality.small240]) {
playerViewController?.player = AVPlayer(url: streamURL)
} else {
self.dismiss(animated: true, completion: nil)
}
}
}