我尝试创建一个演示应用程序以从iOS应用程序投射视频,但是,投射过程非常完美,因为我可以移动它在chrome投射中反映的音量按钮,但是它不能播放媒体,但是显示其连接。
可以在以下git中查看代码。
https://github.com/DipeshPokhrel/ChromecastDemo
下面是创建元数据的代码段(我认为我缺少某些内容的部分)
GCKMediaMetadata *metadata = [[GCKMediaMetadata alloc] initWithMetadataType:GCKMediaMetadataTypeTVShow];
[metadata setString:@"Hello" forKey:kGCKMetadataKeyTitle];
[metadata setString:@"Subtitle" forKey:@"description"];
[metadata setString: @"Hello moto" forKey:kGCKMetadataKeyStudio];
[metadata addImage:[[GCKImage alloc] initWithURL:[NSURL URLWithString:CHROMECAST_STAGING_IMAGE_URL]
width:320
height:480]];
[metadata addImage:[[GCKImage alloc] initWithURL:[NSURL URLWithString:CHROMECAST_PRODUCTION_IMAGE_URL]
width:320
height:480]];
NSURL *url = [NSURL URLWithString:@"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/GoogleIO-2014-CastingToTheFuture.mp4"];
GCKMediaInformation *mediaInfo = [[GCKMediaInformation alloc]
initWithContentID:[url absoluteString]
streamType:GCKMediaStreamTypeBuffered
contentType:@"video/mp4"
metadata:metadata
streamDuration:0
mediaTracks:nil
textTrackStyle:nil
customData:nil];
GCKCastSession *session =
[GCKCastContext sharedInstance].sessionManager.currentCastSession;
if (session) {
GCKMediaLoadOptions *options = [[GCKMediaLoadOptions alloc]init];
options.autoplay = YES;
[session.remoteMediaClient loadMedia:mediaInfo withOptions:options];
}
我看不到顶部的任何媒体。