如何使youtube视频退出全屏时,视频完成



我正在使用Youtube iOS API helper来显示视频。大多数用户都希望全屏观看视频,但在观看完视频后,应用需要退出全屏视频,用户才能完成相关任务。是否有办法退出视频在videoEnded。

playerVars字典中,您应该设置一个属性@"autohide" : @1这将使视频退出全屏后,视频完成。它看起来像这样:

NSDictionary *playerVars = @{@"autohide" : @1};
[self.playerView loadWithVideoId:self.videoID playerVars:playerVars];

这是我的工作,源https://gist.github.com/akisute/a46c5ec54d27f73b62da

- (void)exitFullScreenVideo:(BOOL)animated completion:(void (^)(void))completion
    {
        if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0) {
            BOOL isFullScreenVideoContent = NO;
            for (UIWindow *window in [UIApplication sharedApplication].windows) {
                if ([window.rootViewController.presentedViewController isKindOfClass:NSClassFromString(@"AVFullScreenViewController")]) {
                    [window.rootViewController dismissViewControllerAnimated:animated completion:^{
                        window.rootViewController = nil;
                        window.hidden = YES;
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
                        [window performSelector:NSSelectorFromString(@"release")];
    #pragma clang diagnostic pop
                        completion();
                    }];
                    isFullScreenVideoContent = YES;
                    break;
                }
            }
            if (!isFullScreenVideoContent) {
                completion();
            }
        } else {
            completion();
        }
    }

相关内容

  • 没有找到相关文章