Queue changes image to Chromecast using GCKMediaQueueItem

I would like to send multiple images to a Chromecast and use them as a splash screen.
I can send them one by one with help [self.mediaControlChannel loadMedia:mediaInformation];

, but when I wanted to use the capabilities of the queues, I ran into problems.

I first tried using queueLoadItems:

to load multiples GCKMediaQueueItem

:

GCKMediaInformation *mediaInformation = [[GCKMediaInformation alloc] initWithContentID:[url absoluteString]
                                                                            streamType:GCKMediaStreamTypeNone
                                                                           contentType:@"image/jpeg"
                                                                              metadata:nil
                                                                        streamDuration:5
                                                                            customData:nil];

GCKMediaQueueItem *mediaQueue =  [[GCKMediaQueueItem alloc] initWithMediaInformation:mediaInformation
                                                                            autoplay:true
                                                                           startTime:startTime
                                                                         preloadTime:3.0f
                                                                      activeTrackIDs:nil
                                                                          customData:nil];


[mediaArray addObject:mediaQueue];



NSInteger requestId = [self.mediaControlChannel queueLoadItems:mediaArray startIndex:0 repeatMode:GCKMediaRepeatModeAllAndShuffle ];
if (requestId == kGCKInvalidRequestID) {
    NSLog(@"WARN queueLoadItems: the message could not be sent");
} else {
    NSLog(@"queueLoadItems: OK");  
}

      

But success is not possible even if - (void)mediaControlChannel:(GCKMediaControlChannel *)mediaControlChannel didCompleteLoadWithSessionID:(NSInteger)sessionID

called and the image of the first GCKMediaQueue object is displayed on the TV screen. The second GCKMediaQueueItem

never appears.

I tried to force the move to the next item [self.mediaControlChannel queueNextItem];

, but no luck. If I check how many items are in the queue with [[self.mediaControlChannel mediaStatus] queueItemCount]

, I get "0", which means the queue is empty.

And if I set startIndex:1

, for example, the second item is displayed on the TV. So it looks like all items are loaded.

Then I tried to use [self.mediaControlChannel queueInsertItem:mediaQueue beforeItemWithID:kGCKMediaQueueInvalidItemID];

and again I have the same problem: only the first image of the queue is visible and I have 0 items in mine queueItemCount:

.

If I turn on the logger I got this message:

-[GCKMediaControlChannel mediaSessionID]  Calling a method that requires a media status with no media status, ignoring; 
make sure that media is loaded, the media channel has received a status, and that this method is not being called while the device manager is attempting to reconnect

      

So, I tried to insert items after the call didCompleteLoadWithSessionID

. The message went away, but I still have no items inqueueItemCount:

If I keep looking in the logs I found these lines:

-[GCKMediaControlChannel didReceiveTextMessage:]  message received: {"requestId":7,"type":"INVALID_REQUEST","reason":"INVALID_MEDIA_SESSION_ID"}
-[GCKMediaControlChannel didReceiveTextMessage:]  Received unexpected error: Invalid Request.

      

Thanks to this question, I know that I can use a custom receiver to host multiples with loadMedia:

and a custom receiver, but it looks like I'm trying to do this with the default receiver and the latest SDK update (2.7).

Any help would be greatly appreciated.

+3


source to share


2 answers


Default / style receivers handle queues of audio or video elements, but not images; this is because the receiver SDK's service capabilities are built around these two types of media, not images. There is a "duration" with the audio / video element and they start to play and they reach their end, at which time the SDK moves on to the next element (it basically learns about the end of the element by listening to MediaElement events) With images and an image tag you have there is no such thing, so the SDK doesn't try to do anything. In short, you will need to write your own custom receiver, and you are unlikely to be able to benefit from the queue API even on the sender side; you need to send "messages" (in your own namespace) with image urls (and other information,which you need) into your receiver and then in your custom receiver get an array of images and push them into an image tag one by one or something like that.



+2


source


Idk if you are still looking for a solution but it worked for me

NSMutableArray *mediaArray = [NSMutableArray array];
[mediaArray addObject:mediaQueue];

      



Since NSArray is not a "mutable" class, that is, it is not intended to be modified after it has been created.

0


source







All Articles