1

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
Brian M
  • 331
  • 3
  • 10
  • Does this answer your question? [skipPrevious and skipNext buttons inactive even with items in queue Google Cast iOS Sender SDK v4.3.5 and above](https://stackoverflow.com/questions/57633156/skipprevious-and-skipnext-buttons-inactive-even-with-items-in-queue-google-cast) – Richard II Sep 10 '21 at 16:37

0 Answers0