• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

YTPlayerView youtube-ios-player-helper 暂停不起作用

用户头像
it1352
帮助1

问题说明

我在使用 Youtube youtube-ios-player-helper 库时遇到问题.我可以将视频加载到播放器中并播放,但如果我点击暂停,视频会停止几秒钟,然后再次开始播放.

I'm having trouble with the Youtube youtube-ios-player-helper library. I can load a video into the player and it plays but if I tap pause the video stops for a few seconds and then starts playing again.

启动视频的极其简单的 UIViewController 代码是:

The incredibly simple UIViewController code to start the video is:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.player = [[YTPlayerView alloc] initWithFrame:CGRectMake(X, Y, WIDTH, HEIGHT)];

    self.player.delegate = self;
    [self.view addSubview:self.player];
    [self.player loadWithVideoId:@"bQCjOm4p5jM"];

}

我使用 NSLog 检测 didChangeToState 委托方法如下:

I instrumented the didChangeToState delegate method with NSLog as follows:

- (void)playerView:(YTPlayerView *)playerView didChangeToState:(YTPlayerState)state {
    switch (state) {
        case kYTPlayerStatePlaying:
            NSLog(@"Started playback");
            break;
        case kYTPlayerStatePaused:
            NSLog(@"Paused playback");
            break;
        default:
            NSLog(@"didChangeToState %d", state);
            break;
    }
}

在 Xcode 日志中,当我点击播放"开始播放视频时,我看到:

In the Xcode log, when I tap 'play' to start the video playing, I see:

didChangeToState 4

值 4 似乎没有在 YTPlayerView.m 中定义.当视频真正开始播放时,我会看到预期的 Started play 日志消息.

The value 4 does not appear to be defined in YTPlayerView.m. When the video actually starts playing I see the expected Started playback log message.

当我点击暂停"时,我在日志中看不到任何内容(没有触发 didChangeToState 事件 - 我期望的事件是 kYTPlayerStatePaused 每个YTPlayerView 文档).然而,几秒钟后,视频又开始播放,然后我看到两个连续的 Startedplayed 日志消息(kYTPlayerStatePlaying 事件).每次我按暂停"尝试暂停视频时,它都会暂停几秒钟(没有 kYTPlayerStatePaused 事件),但随后它又开始播放,我看到 Startedplayed代码> 日志消息.

When I tap 'pause', I don't see anything in the log (no didChangeToState event triggered - the event I'd expect would be kYTPlayerStatePaused per the YTPlayerView docs). However a few seconds later, the video starts playing again, and then I see two consecutive Started playback log messages (kYTPlayerStatePlaying events). Every time I press 'pause' to try to pause the video, it pauses for a few seconds (with no kYTPlayerStatePaused event), but then it starts playing again and I see Started playback log messages.

还有人看到这个吗?有谁知道从这里去哪里?这是 Xcode 6.2,构建目标是 iOS 8.0.

Anyone else seeing this? Anyone know where to go from here? This is Xcode 6.2 and build target is iOS 8.0.

正确答案

#1

我在 Github 问题跟踪器中找到了代码的解决方案.抱歉,我想我在之前的研究中错过了这一点.

I found a solution here in the Github issue tracker for the code. Sorry, I guess I missed that in my earlier researching.

描述的修复在这里:https://github.com/youtube/youtube-ios-player-helper/issues/86

YTPlayerView-iframe-player.html中,删除或注释下面的代码.

In YTPlayerView-iframe-player.html, remove or comment below code.

window.setInterval(forcePlay, 5000);

还有另一个建议的修复程序可以完全替换 YTPlayerView-iframe-player.html 文件,但以上似乎对我有用.我担心 Google 自己的这个基本功能的代码从根本上被破坏了.

There's another suggested fix that completely replaces the YTPlayerView-iframe-player.html file but the above seems to have worked for me. It concerns me that Google's own code for this basic function is so fundamentally broken.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgaheg
系列文章
更多 icon
同类精品
更多 icon
继续加载