Я пытаюсь Chromecast воспроизвести мое видео с локальными URL.Я не знаю, как реализовать, ниже приведен код, который пытался, я не мог найти много библиотек, чтобы делать Chromecast с локальным URL и воспроизводить видео, управляя телефоном как удаленным (воспроизведение / остановка).Если кто-нибудь знает, может помочь с хорошими библиотеками или предложить код для него.Пожалуйста ..
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)
}}