Search code examples
ioschromecastgoogle-cast

How to make casting video loop


Is there anyway to make a video loop? I have the app working and the video streams but I want it to replay again as soon as it ends. Is there a simple option to add a loop option?

{
GCKMediaMetadata *metadata = [[GCKMediaMetadata alloc] init];

[metadata setString:@"Title" forKey:kGCKMetadataKeyTitle];

[metadata setString:@"www.website.com"

             forKey:kGCKMetadataKeySubtitle];

[metadata addImage:[[GCKImage alloc]
                    initWithURL:[[NSURL alloc] initWithString:@"http://www.website.com/thumbnail.png"]
                    width:480
                    height:360]];
// [END media-metadata]

// Define Media information.
// [START load-media]
GCKMediaInformation *mediaInformation =
[[GCKMediaInformation alloc] initWithContentID:
 @"http://www.website.com/video.mp4"
                                    streamType:GCKMediaStreamTypeNone
                                   contentType:@"video/mp4"
                                      metadata:metadata
                                streamDuration:0
                                    customData:nil];

// Cast the video.
[_mediaControlChannel loadMedia:mediaInformation autoplay:YES playPosition:0];
// [END load-media]
}

Solution

  • One option is to build a queue of one item with the "repeat" flag turned on.