skipNext skipPrevious Google Cast greyed out

人盡茶涼 提交于 2020-01-03 03:00:07

问题


As it pertains to How to add/use GCKMediaQueue in Swift? I have added the skip buttons on AppDelegate, and they do appear on the expanded controller screen. But they are greyed out. If I let a video end, then it will play the next in the queue. But then why are the buttons greyed out? That usually means that they are not available to use. But I have 50 videos in the queue, so what am I missing?

func addvideos2queue() {
for indexloop in 1 ... 50
       {

        debugPrint("**** Attempting #" + String(indexloop) + " to add another to the que")
            let PTV = playthisvideo() //received random video file name
            let metadata = GCKMediaMetadata()
            metadata.setString("Los Simpsons", forKey: kGCKMetadataKeyTitle)
            metadata.addImage(GCKImage(url: URL(string: self.location + "poster_los_simpson.jpg")!,
                                       width: 480,
                                       height: 360))
            metadata.setString (PTV,
                                forKey: kGCKMetadataKeySubtitle)

            let url = URL.init(string: (self.location + PTV))
            guard let mediaURL = url else {
                print("**** invalid mediaURL")
                return }
            if url == nil {debugPrint("***** URL  was empty")}
            let mediaInfoBuilder = GCKMediaInformationBuilder.init(contentURL: mediaURL)
            mediaInfoBuilder.streamType = GCKMediaStreamType.none;
            mediaInfoBuilder.contentType = "video/mp4"
            mediaInfoBuilder.contentID = String(indexloop)
            mediaInfoBuilder.metadata = metadata;
            let builder = GCKMediaQueueItemBuilder()
            let mediaInformation = mediaInfoBuilder.build()
            builder.mediaInformation = mediaInformation
            builder.autoplay = true
            builder.preloadTime = 15
            let item = builder.build

        if let remoteMediaClient = GCKCastContext.sharedInstance().sessionManager.currentCastSession?.remoteMediaClient {

            if remoteMediaClient.mediaStatus != nil, true {
                let request = remoteMediaClient.queueInsert([item()], beforeItemWithID: kGCKMediaQueueInvalidItemID, customData: kGCKMediaCommandSkipForward)
                request.delegate = self
                debugPrint(" *****  ITS BEEN ADDED ****", request)
                setQueueButtonVisible(true)
            } else {
                let options = GCKMediaQueueLoadOptions()
                options.repeatMode = .all
               options.customData =  kGCKMediaCommandSkipForward
                debugPrint (" ************* First one ", (item()))
                let request = remoteMediaClient.queueLoad([item()], with: options )
                request.delegate = self

            }

        }




}//new end of loop

GCKCastContext.sharedInstance().presentDefaultExpandedMediaControls() // Brings to expaned controller up
}//end of castanthoner

来源:https://stackoverflow.com/questions/55210582/skipnext-skipprevious-google-cast-greyed-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!