Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bufferingSomeSecond 暂停播放后一定不会继续播放? #1438

Open
Sunshineyg00 opened this issue Sep 11, 2024 · 0 comments
Open

bufferingSomeSecond 暂停播放后一定不会继续播放? #1438

Sunshineyg00 opened this issue Sep 11, 2024 · 0 comments

Comments

@Sunshineyg00
Copy link

Sunshineyg00 commented Sep 11, 2024

buffer为空时,先设置 loadState 为 ZFPlayerLoadStateStalled:

           if (self.playerItem.playbackBufferEmpty) {
                self.loadState = ZFPlayerLoadStateStalled;
                [self bufferingSomeSecond];
            }

然后在bufferingSomeSecond方法中,调用了pause,把 isPlaying 设置为 NO

    [self pause];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        // 如果此时用户已经暂停了,则不再需要开启播放了
        if (!self.isPlaying && self.loadState == ZFPlayerLoadStateStalled) {
            self.isBuffering = NO;
            return;
        }
        [self play];
        // 如果执行了play还是没有播放则说明还没有缓存好,则再次缓存一段时间
        self.isBuffering = NO;
        if (!self.playerItem.isPlaybackLikelyToKeepUp) [self bufferingSomeSecond];
    });

那过了3s,“!self.isPlaying && self.loadState == ZFPlayerLoadStateStalled” 总是为 YES,就会直接 return 了,不会执行下面尝试 play、或者继续 bufferingSomeSecond 的代码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant