作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 playSelectedItemRemotely 方法中,我收到一条警告消息:
- (void)playSelectedItemRemotely {
GCKCastSession* castSession = [GCKCastContext sharedInstance].sessionManager.currentCastSession;
if (castSession) {
// WARNING ON LINE BELOW
[castSession.remoteMediaClient loadMedia:[self buildMediaInformation] autoplay:YES];
} else {
NSLog(@"No cast session!");
}
}
说:
'loadMedia:autoplay:' is deprecated: Use loadMedia:withOptions:
如何解决这个问题?
最佳答案
就像警告消息所说,您可以使用 loadMedia:withOptions 方法,如下所示:
- (void)playSelectedItemRemotely {
GCKCastSession* castSession = [GCKCastContext sharedInstance].sessionManager.currentCastSession;
if (castSession) {
GCKMediaLoadOptions *options = [GCKMediaLoadOptions init];
[castSession.remoteMediaClient loadMedia:[self buildMediaInformation] withOptions:options];
} else {
BILog(@"No cast session!");
}
}
以下是您可以使用的选项:
- (BOOL) autoplay Whether playback should start immediately.
The default value is YES.
- (NSTimeInterval) playPosition The initial playback position.
The default value is kGCKInvalidTimeInterval, which indicates a default playback position.
- (float) playbackRate The playback rate.
The default value is 1.
- (NSArray*) activeTrackIDs An array of integers specifying the active tracks.
The default value is nil.
- (id) customData Custom application-specific data to pass along with the request.
Must either be an object that can be serialized to JSON using NSJSONSerialization, or nil.
- (NSString*) credentials
The user credentials for the media item being loaded.
- (NSString*) credentialsType
The type of user credentials specified in GCKMediaLoadOptions::credentials.
另请检查the documentation .
关于ios - Chromecast 警告 loadMedia 自动播放已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55155419/
我是一名优秀的程序员,十分优秀!