【问题标题】:ChromeCast Video with iOS App using local url (Error)使用本地 URL 的 iOS 应用程序的 ChromeCast 视频(错误)
【发布时间】:2019-04-30 03:32:11
【问题描述】:

我正在尝试使用 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)
    }}

【问题讨论】:

    标签: ios arrays swift chromecast google-cast


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2016-11-14
      • 2014-03-13
      • 1970-01-01
      • 1970-01-01
      • 2014-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      相关资源
      最近更新 更多