-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d639c47
commit 801c6cf
Showing
9 changed files
with
271 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
SJBaseVideoPlayer/AliPlayer/Core/SJAliMediaPlayerInternal.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// SJAliMediaPlayerInternal.h | ||
// Pods | ||
// | ||
// Created by 畅三江 on 2022/9/15. | ||
// | ||
|
||
#ifndef SJAliMediaPlayerInternal_h | ||
#define SJAliMediaPlayerInternal_h | ||
|
||
|
||
#import "SJAliMediaPlayer.h" | ||
#import <AliyunPlayer/AliyunPlayer.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
@interface SJAliMediaPlayer (Internal) | ||
@property (nonatomic, strong, readonly) AliPlayer *player; | ||
@end | ||
NS_ASSUME_NONNULL_END | ||
#endif /* SJAliMediaPlayerInternal_h */ |
27 changes: 27 additions & 0 deletions
27
SJBaseVideoPlayer/AliPlayer/Core/SJAliPictureInPictureController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// SJAliPictureInPictureController.h | ||
// SJBaseVideoPlayer.common-AliPlayer-IJKPlayer | ||
// | ||
// Created by 畅三江 on 2022/9/15. | ||
// | ||
|
||
#import "SJPictureInPictureControllerDefines.h" | ||
@class SJAliMediaPlayer; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
/// 目前仅支持配置: canStartPictureInPictureAutomaticallyFromInline(App进入后台是否自动进入画中画) | ||
/// | ||
API_AVAILABLE(ios(15.0)) @interface SJAliPictureInPictureController : NSObject<SJPictureInPictureController> | ||
+ (BOOL)isPictureInPictureSupported; | ||
- (instancetype)initWithPlayer:(SJAliMediaPlayer *)player delegate:(id<SJPictureInPictureControllerDelegate>)delegate; | ||
|
||
@property (nonatomic, weak, readonly, nullable) SJAliMediaPlayer *player; | ||
|
||
@property (nonatomic) BOOL requiresLinearPlayback; | ||
@property (nonatomic) BOOL canStartPictureInPictureAutomaticallyFromInline; | ||
@property (nonatomic, weak, nullable) id<SJPictureInPictureControllerDelegate> delegate; | ||
@property (nonatomic, readonly) SJPictureInPictureStatus status; | ||
- (void)startPictureInPicture; | ||
- (void)stopPictureInPicture; | ||
@end | ||
NS_ASSUME_NONNULL_END |
128 changes: 128 additions & 0 deletions
128
SJBaseVideoPlayer/AliPlayer/Core/SJAliPictureInPictureController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// | ||
// SJAliPictureInPictureController.m | ||
// SJBaseVideoPlayer.common-AliPlayer-IJKPlayer | ||
// | ||
// Created by 畅三江 on 2022/9/15. | ||
// | ||
|
||
#if __has_include(<AliyunPlayer/AliPlayerPictureInPictureDelegate.h>) | ||
#import "SJAliPictureInPictureController.h" | ||
#import <AVKit/AVPictureInPictureController.h> | ||
#import "SJAliMediaPlayerInternal.h" | ||
#import <AliyunPlayer/AliPlayerPictureInPictureDelegate.h> | ||
|
||
@interface SJAliPictureInPictureController ()<AliPlayerPictureInPictureDelegate> | ||
@property (nonatomic) SJPictureInPictureStatus status; | ||
@end | ||
|
||
@implementation SJAliPictureInPictureController | ||
|
||
+ (BOOL)isPictureInPictureSupported { | ||
return AVPictureInPictureController.isPictureInPictureSupported; | ||
} | ||
|
||
- (instancetype)initWithPlayer:(SJAliMediaPlayer *)player delegate:(nonnull id<SJPictureInPictureControllerDelegate>)delegate { | ||
self = [super init]; | ||
if ( self ) { | ||
_player = player; | ||
_delegate = delegate; | ||
_player.player.pictureInPictureDelegate = self; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setRequiresLinearPlayback:(BOOL)requiresLinearPlayback { | ||
#ifdef DEBUG | ||
NSLog(@"%d - -[%@ %s] 暂未提供相关API", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
} | ||
|
||
- (BOOL)requiresLinearPlayback { | ||
#ifdef DEBUG | ||
NSLog(@"%d - -[%@ %s] 暂未提供相关API", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
return NO; | ||
} | ||
|
||
- (void)setCanStartPictureInPictureAutomaticallyFromInline:(BOOL)canStartPictureInPictureAutomaticallyFromInline { | ||
if ( canStartPictureInPictureAutomaticallyFromInline != _canStartPictureInPictureAutomaticallyFromInline ) { | ||
_canStartPictureInPictureAutomaticallyFromInline = canStartPictureInPictureAutomaticallyFromInline; | ||
[_player.player setPictureInPictureEnable:canStartPictureInPictureAutomaticallyFromInline]; | ||
} | ||
} | ||
|
||
- (void)startPictureInPicture { | ||
#ifdef DEBUG | ||
NSLog(@"%d - -[%@ %s] 暂未提供相关API", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
} | ||
|
||
- (void)stopPictureInPicture { | ||
//#ifdef DEBUG | ||
// NSLog(@"%d - -[%@ %s] 暂未提供相关API", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
//#endif | ||
self.canStartPictureInPictureAutomaticallyFromInline = NO; | ||
} | ||
|
||
- (void)setStatus:(SJPictureInPictureStatus)status { | ||
if ( status != _status ) { | ||
_status = status; | ||
|
||
if ( [self.delegate respondsToSelector:@selector(pictureInPictureController:statusDidChange:)] ) { | ||
[self.delegate pictureInPictureController:self statusDidChange:status]; | ||
} | ||
} | ||
} | ||
|
||
#pragma mark - AliPlayerPictureInPictureDelegate | ||
|
||
- (void)pictureInPictureControllerWillStartPictureInPicture { | ||
#ifdef SJDEBUG | ||
NSLog(@"%d - -[%@ %s]", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
self.status = SJPictureInPictureStatusStarting; | ||
} | ||
|
||
- (void)pictureInPictureControllerDidStartPictureInPicture { | ||
#ifdef SJDEBUG | ||
NSLog(@"%d - -[%@ %s]", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
self.status = SJPictureInPictureStatusRunning; | ||
} | ||
|
||
/// 画中画返回app界面,后是否要停止 | ||
- (BOOL)pictureInPictureIsPlaybackPaused { | ||
#ifdef SJDEBUG | ||
NSLog(@"%d - -[%@ %s]", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
return NO; | ||
} | ||
|
||
- (void)pictureInPictureControllerWillStopPictureInPicture { | ||
#ifdef SJDEBUG | ||
NSLog(@"%d - -[%@ %s]", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
self.status = SJPictureInPictureStatusStopping; | ||
} | ||
|
||
- (void)pictureInPictureControllerDidStopPictureInPicture { | ||
#ifdef SJDEBUG | ||
NSLog(@"%d - -[%@ %s]", (int)__LINE__, NSStringFromClass([self class]), sel_getName(_cmd)); | ||
#endif | ||
self.status = SJPictureInPictureStatusStopped; | ||
} | ||
@end | ||
#else | ||
@implementation SJAliPictureInPictureController | ||
+ (BOOL)isPictureInPictureSupported { | ||
return NO; | ||
} | ||
|
||
- (instancetype)initWithPlayer:(SJAliMediaPlayer *)player delegate:(id<SJPictureInPictureControllerDelegate>)delegate { | ||
return nil; | ||
} | ||
|
||
- (void)startPictureInPicture { } | ||
- (void)stopPictureInPicture { } | ||
@end | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.