Skip to content

Commit

Permalink
Release 3.4.3
Browse files Browse the repository at this point in the history
- 修改`Reachability`的依赖, 改为内部直接引用
- 完善hls在14.0进入前台后不播放的问题
  • Loading branch information
changsanjiang committed Nov 20, 2020
1 parent 497d66a commit 3812e14
Show file tree
Hide file tree
Showing 9 changed files with 621 additions and 68 deletions.
3 changes: 1 addition & 2 deletions SJBaseVideoPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SJBaseVideoPlayer'
s.version = '3.4.2'
s.version = '3.4.3'
s.summary = 'video player.'
s.description = 'https://github.com/changsanjiang/SJBaseVideoPlayer/blob/master/README.md'
s.homepage = 'https://github.com/changsanjiang/SJBaseVideoPlayer'
Expand Down Expand Up @@ -58,5 +58,4 @@ Pod::Spec.new do |s|
s.dependency 'SJUIKit/ObserverHelper'
s.dependency 'SJUIKit/Queues'
s.dependency 'SJUIKit/SQLite3'
s.dependency 'Reachability'
end
2 changes: 1 addition & 1 deletion SJBaseVideoPlayer/AVPlayer/Core/AVAsset+SJAVMediaExport.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ - (void)exportWithStartTime:(NSTimeInterval)startTime
CMTimeRange cutRange = CMTimeRangeMake(CMTimeMakeWithSeconds(startTime, NSEC_PER_SEC), CMTimeMakeWithSeconds(endTime - startTime, NSEC_PER_SEC));
AVAssetTrack *assetAudioTrack = [asset tracksWithMediaType:AVMediaTypeAudio].firstObject;
AVAssetTrack *assetVideoTrack = [asset tracksWithMediaType:AVMediaTypeVideo].firstObject;
NSError *error;
NSError *error = nil;
[audioTrackM insertTimeRange:cutRange ofTrack:assetAudioTrack atTime:kCMTimeZero error:&error];
if ( error ) { NSLog(@"Export Failed: error = %@", error); if ( failure ) failure(self.asset, error); return;}
[videoTrackM insertTimeRange:cutRange ofTrack:assetVideoTrack atTime:kCMTimeZero error:&error];
Expand Down
18 changes: 16 additions & 2 deletions SJBaseVideoPlayer/AVPlayer/SJAVMediaPlaybackController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
NS_ASSUME_NONNULL_BEGIN
@interface SJAVMediaPlaybackController ()<SJPictureInPictureControllerDelegate>
@property (nonatomic, strong, nullable) SJAVPictureInPictureController *pictureInPictureController API_AVAILABLE(ios(14.0));
// https://github.com/changsanjiang/SJVideoPlayer/issues/339
@property (nonatomic) BOOL needsToRefresh_fix339 API_AVAILABLE(ios(14.0));
@end

@implementation SJAVMediaPlaybackController
Expand Down Expand Up @@ -72,8 +74,9 @@ - (void)receivedApplicationDidBecomeActiveNotification {
if ( @available(iOS 14.0, *) ) {
if ( self.pauseWhenAppDidEnterBackground ) {
if ( self.media.isM3u8 && self.timeControlStatus == SJPlaybackTimeControlStatusPaused ) {
[self refresh];
[self pause];
self.needsToRefresh_fix339 = YES;
// [self refresh];
// [self pause];
return;
}
}
Expand Down Expand Up @@ -188,17 +191,28 @@ - (void)setMinBufferedDuration:(NSTimeInterval)minBufferedDuration {
- (void)refresh {
if ( self.media != nil ) [SJAVMediaPlayerLoader clearPlayerForMedia:self.media];
if ( @available(iOS 14.0, *) ) {
self.needsToRefresh_fix339 = NO;
[self cancelPictureInPicture];
}
[self cancelGenerateGIFOperation];
[self cancelExportOperation];
[super refresh];
}

- (void)play {
if (@available(iOS 14.0, *)) {
self.needsToRefresh_fix339 ? [self refresh] : [super play];
}
else {
[super play];
}
}

- (void)stop {
[self cancelGenerateGIFOperation];
[self cancelExportOperation];
if ( @available(iOS 14.0, *) ) {
self.needsToRefresh_fix339 = NO;
[self cancelPictureInPicture];
}
[super stop];
Expand Down
35 changes: 32 additions & 3 deletions SJBaseVideoPlayer/Common/Implements/SJMediaPlaybackController.m
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,38 @@ - (void)_initObservations {
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(audioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(audioSessionRouteChange:) name:AVAudioSessionRouteChangeNotification object:nil];

[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(receivedApplicationDidBecomeActiveNotification) name:UIApplicationDidBecomeActiveNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(receivedApplicationWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(receivedApplicationDidEnterBackgroundNotification) name:UIApplicationDidEnterBackgroundNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_receivedApplicationDidBecomeActiveNotification) name:UIApplicationDidBecomeActiveNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_receivedApplicationWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_receivedApplicationWillEnterForegroundNotification) name:UIApplicationWillEnterForegroundNotification object:nil];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_receivedApplicationDidEnterBackgroundNotification) name:UIApplicationDidEnterBackgroundNotification object:nil];
}

- (void)_receivedApplicationDidBecomeActiveNotification {
[self receivedApplicationDidBecomeActiveNotification];
if ( [self.delegate respondsToSelector:@selector(applicationDidBecomeActiveWithPlaybackController:)] ) {
[self.delegate applicationDidBecomeActiveWithPlaybackController:self];
}
}

- (void)_receivedApplicationWillResignActiveNotification {
[self receivedApplicationWillResignActiveNotification];
if ( [self.delegate respondsToSelector:@selector(applicationWillResignActiveWithPlaybackController:)] ) {
[self.delegate applicationWillResignActiveWithPlaybackController:self];
}
}

- (void)_receivedApplicationWillEnterForegroundNotification {
[self receivedApplicationWillEnterForegroundNotification];
if ( [self.delegate respondsToSelector:@selector(applicationWillEnterForegroundWithPlaybackController:)] ) {
[self.delegate applicationWillEnterForegroundWithPlaybackController:self];
}
}

- (void)_receivedApplicationDidEnterBackgroundNotification {
[self receivedApplicationDidEnterBackgroundNotification];
if ( [self.delegate respondsToSelector:@selector(applicationDidEnterBackgroundWithPlaybackController:)] ) {
[self.delegate applicationDidEnterBackgroundWithPlaybackController:self];
}
}

- (void)playerAssetStatusDidChange:(NSNotification *)note {
Expand Down
Loading

0 comments on commit 3812e14

Please sign in to comment.