ChromeCast视频与iOS应用程序使用本地url(错误)



我正在尝试Chromecast播放我的本地url视频。我不熟悉如何实现,下面是尝试过的代码,我找不到太多的库来使用本地url进行Chromecast,并通过远程控制手机来播放视频(播放/停止(。如果有人知道可以用好的库来指导或建议代码。请。。

override func viewDidLoad() {
super.viewDidLoad()
let castButton = GCKUICastButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24))
castButton.tintColor = UIColor.red
let castBarButtonItem = UIBarButtonItem(customView: castButton)
navigationItem.rightBarButtonItem = castBarButtonItem
Casty.shared.initialize()
let url: String  = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
let subtitleURL = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/tracks/DesigningForGoogleCast-en.vtt"
let subtitle = GCKMediaTrack(identifier: 1, contentIdentifier: subtitleURL , contentType: "text/vtt", type: GCKMediaTrackType.text, textSubtype: GCKMediaTextTrackSubtype.captions, name: "English", languageCode: "en", customData: nil)
//this image will show up in expanded controller as well as video thumb
let image = GCKImage(url: URL(string: "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/images/780x1200/DesigningForGoogleCast-887x1200.jpg")!, width: 780, height: 1200)
Casty.didStartSession = { _ in
Casty.shared.loadMedia(url: self.url , subtitles: [subtitle] , activeSubtitleID: 1 , title: "Dev" , image: image)
Casty.shared.presentExpandedController()
Casty.shared.addMiniController(toParentViewController: self)
}}

Cast媒体播放器仅支持通过HTTP进行播放。因此,您需要有一个本地网络服务器,允许玩家访问您的本地内容。

相关内容

  • 没有找到相关文章

最新更新