繁体   English   中英

带有iOS应用的ChromeCast视频(使用本地网址)(错误)

[英]ChromeCast Video with iOS App using local url (Error)

我正在尝试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播放。 因此,您将需要具有本地Web服务器,以允许播放器访问您的本地内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM