Google Chrome演员无法播放视频

时间:2018-06-05 08:21:05

标签: ios objective-c google-cast

我正在开发一款iOS APP,可以通过iPhone-iOS App的Chromecast投放视频。集成了Google Chrome演员版SDKv4。 Cast按钮发现了接收器,但它没有显示视频,但视频正在iPhone中播放

NSURL *videoURL = [NSURL URLWithString:@"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"];

AVPlayerItem *item = [AVPlayerItem playerItemWithURL:videoURL];
player = [AVPlayer playerWithPlayerItem:item];
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = _localPlayerView.frame;
controller.player = player;
controller.showsPlaybackControls = YES;
player.closedCaptionDisplayEnabled = NO;

GCKMediaMetadata *metadata =
[[GCKMediaMetadata alloc] initWithMetadataType:GCKMediaMetadataTypeMovie          ];
GCKMediaInformation *mediaInfo = [[GCKMediaInformation alloc]
                                  initWithContentID:[videoURL absoluteString]
                                  streamType:GCKMediaStreamTypeBuffered
                                  contentType:@"video/mp4"
                                  metadata:metadata
                                  streamDuration:100
                                  mediaTracks:nil
                                  textTrackStyle:nil
                                  customData:nil];

GCKCastSession *session =
[GCKCastContext sharedInstance].sessionManager.currentCastSession;

[[GCKCastContext sharedInstance].sessionManager addListener:self];
[session.remoteMediaClient loadMedia:mediaInfo];
[session start];

0 个答案:

没有答案