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

Update SJAVMediaPlayerLoader.m #20

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ - (void)play {
_reasonForWaitingToPlay = SJWaitingWhileEvaluatingBufferingRateReason;
self.timeControlStatus = SJPlaybackTimeControlStatusWaitingToPlay;
}

[self.avPlayer play];
self.avPlayer.rate = self.rate;
// fix 播放后立即设置倍速,可能会导致画面卡住的问题, 直接使用系统提供api设置倍速播放
if (@available(iOS 10.0, *)) {
[self.avPlayer playImmediatelyAtRate:self.rate];
} else {
[self.avPlayer play];
self.avPlayer.rate = self.rate;
}
[self _toEvaluating];
}

Expand Down
3 changes: 2 additions & 1 deletion SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayerLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ + (nullable SJAVMediaPlayer *)loadPlayerForMedia:(SJVideoPlayerURLAsset *)media
// fix: https://github.com/changsanjiang/SJBaseVideoPlayer/pull/17 & https://github.com/changsanjiang/SJBaseVideoPlayer/issues/18
//
// 重新创建playerItem规避`An AVPlayerItem cannot be associated with more than one instance of AVPlayer`错误.
if (avPlayerItem != nil && avPlayerItem.status == AVPlayerStatusFailed) {
// 发现播放视频(缓冲一部分)然后断网, 出现重新播放点击后,依然会出现上述崩溃 其状态为 AVPlayerStatusReadyToPlay
if (avPlayerItem != nil && avPlayerItem.status != AVPlayerStatusUnknown) {
NSURL *URL = nil;
if ( [avPlayerItem.asset isKindOfClass:AVURLAsset.class] ) {
URL = [(AVURLAsset *)avPlayerItem.asset URL];
Expand Down