我一直在努力做到这一点,但我无法做出可能的检查所有可能的方法可以帮助我,但没有任何作用,我想要做的是使用youtube API播放视频和我必须播放该视频,但没有控制,因为它假设用户无法暂停或奖励视频,但我仍然无法做到这一点,因为你知道YTPlayerView是API提供给我们的类,在这个类中是声明的方法,所以我会告诉你我在这个类和我的viewController连接的类中所做的事情。希望您能够帮助我。谢谢
VideoViewController
#import "VideoViewController.h"
@interface VideoViewController ()
@end
@implementation VideoViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.playerView.delegate = self;
NSDictionary *playerVars = @{ @"controls" : @0 };
[self.playerView loadWithVideoId: @"M7lc1UVf-VE" playerVars: playerVars];
}
-(void)playerViewDidBecomeReady:(YTPlayerView *)playerView{
[[NSNotificationCenter defaultCenter] postNotificationName:@"Playback started" object:self];
[self.playerView playVideo];
}
@end
YTPlayerView.m
- (BOOL)loadWithVideoId:(NSString *)videoId playerVars:(NSDictionary *)playerVars {
if (!playerVars) {
playerVars = @{@"controls" : @0
};
}
NSDictionary *playerParams = @{ @"videoId" : videoId, @"playerVars" : playerVars };
return [self loadWithPlayerParams:playerParams];
}