-
Notifications
You must be signed in to change notification settings - Fork 481
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
e641a03
commit af017ec
Showing
9 changed files
with
428 additions
and
101 deletions.
There are no files selected for viewing
Binary file not shown.
121 changes: 121 additions & 0 deletions
121
Example/Pods/Local Podspecs/SJBaseVideoPlayer.podspec.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Binary file modified
BIN
+55.1 KB
(210%)
.../SJVideoPlayer.xcworkspace/xcuserdata/bdoffice.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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
Binary file not shown.
28 changes: 28 additions & 0 deletions
28
.../Demos/iPhone Demo/Playback List Control(播放列表控制)/SJBaseVideoPlayer+ListPlaybackExtended.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,28 @@ | ||
// | ||
// SJBaseVideoPlayer+ListPlaybackExtended.h | ||
// SJVideoPlayer_Example | ||
// | ||
// Created by BD on 2021/3/13. | ||
// Copyright © 2021 changsanjiang. All rights reserved. | ||
// | ||
|
||
#import "SJBaseVideoPlayer.h" | ||
@protocol SJBaseVideoPlayerAssetProvider; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
@interface SJBaseVideoPlayer (ListPlaybackExtended) | ||
|
||
@property (nonatomic, weak, nullable) id<SJBaseVideoPlayerAssetProvider> assetProvider; | ||
@property (nonatomic) NSInteger numberOfAssets; | ||
@property (nonatomic, readonly) NSInteger currentAssetIndex; | ||
|
||
- (void)playPreviousAsset; | ||
- (void)playNextAsset; | ||
- (void)playAtIndex:(NSInteger)index; | ||
|
||
@end | ||
|
||
@protocol SJBaseVideoPlayerAssetProvider <NSObject> | ||
- (SJVideoPlayerURLAsset *)videoPlayer:(__kindof SJBaseVideoPlayer *)player assetAtIndex:(NSInteger)index; | ||
@end | ||
NS_ASSUME_NONNULL_END |
122 changes: 122 additions & 0 deletions
122
.../Demos/iPhone Demo/Playback List Control(播放列表控制)/SJBaseVideoPlayer+ListPlaybackExtended.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,122 @@ | ||
// | ||
// SJBaseVideoPlayer+ListPlaybackExtended.m | ||
// SJVideoPlayer_Example | ||
// | ||
// Created by BD on 2021/3/13. | ||
// Copyright © 2021 changsanjiang. All rights reserved. | ||
// | ||
|
||
#import "SJBaseVideoPlayer+ListPlaybackExtended.h" | ||
#import <objc/message.h> | ||
#import <SJPlaybackListController/SJPlaybackListController.h> | ||
|
||
@interface SJAssetItem : NSObject<SJMediaInfo> | ||
- (instancetype)initWithIdx:(NSInteger)idx; | ||
@property (nonatomic, readonly) NSInteger id; | ||
@end | ||
|
||
@implementation SJAssetItem | ||
- (instancetype)initWithIdx:(NSInteger)idx { | ||
self = [super init]; | ||
if ( self ) { | ||
_id = idx; | ||
} | ||
return self; | ||
} | ||
@end | ||
|
||
@interface SJBaseVideoPlayer (ListPrivate)<SJPlaybackListControllerDelegate> | ||
@property (nonatomic, strong, readonly) SJPlaybackListController *listController; | ||
@property (nonatomic, strong, readonly) SJPlaybackObservation *mPrivatePlaybackObserver; | ||
@end | ||
|
||
@implementation SJBaseVideoPlayer (ListPrivate) | ||
- (SJPlaybackListController *)listController { | ||
SJPlaybackListController *listController = objc_getAssociatedObject(self, _cmd); | ||
if ( listController == nil ) { | ||
listController = SJPlaybackListController.alloc.init; | ||
listController.delegate = self; | ||
objc_setAssociatedObject(self, _cmd, listController, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
return listController; | ||
} | ||
|
||
- (SJPlaybackObservation *)mPrivatePlaybackObserver { | ||
SJPlaybackObservation *observer = objc_getAssociatedObject(self, _cmd); | ||
if ( observer == nil ) { | ||
observer = [SJPlaybackObservation.alloc initWithPlayer:self]; | ||
objc_setAssociatedObject(self, _cmd, observer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
return observer; | ||
} | ||
|
||
- (void)listController:(id<SJPlaybackListController>)listController needToPlayMedia:(id<SJMediaInfo>)media { | ||
SJVideoPlayerURLAsset *asset = [self.assetProvider videoPlayer:self assetAtIndex:media.id]; | ||
self.URLAsset = asset; | ||
} | ||
|
||
- (void)listController:(id<SJPlaybackListController>)listController needToReplayCurrentMedia:(id<SJMediaInfo>)media { | ||
[self replay]; | ||
} | ||
|
||
- (void)currentMediaForListControllerIsRemoved:(id<SJPlaybackListController>)listController { } | ||
|
||
@end | ||
|
||
@interface SJBaseVideoPlayerAssetProviderWeak : NSObject | ||
@property (nonatomic, weak, nullable) id<SJBaseVideoPlayerAssetProvider> assetProvider; | ||
@end | ||
|
||
@implementation SJBaseVideoPlayerAssetProviderWeak | ||
|
||
@end | ||
|
||
@implementation SJBaseVideoPlayer (ListPlaybackExtended) | ||
|
||
- (void)setAssetProvider:(id<SJBaseVideoPlayerAssetProvider>)assetProvider { | ||
SJBaseVideoPlayerAssetProviderWeak *weak = SJBaseVideoPlayerAssetProviderWeak.alloc.init; | ||
weak.assetProvider = assetProvider; | ||
objc_setAssociatedObject(self, @selector(assetProvider), weak, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
- (nullable id<SJBaseVideoPlayerAssetProvider>)assetProvider { | ||
SJBaseVideoPlayerAssetProviderWeak *weak = objc_getAssociatedObject(self, _cmd); | ||
return weak.assetProvider; | ||
} | ||
|
||
- (void)setNumberOfAssets:(NSInteger)numberOfAssets { | ||
[self.listController removeAllMedias]; | ||
NSMutableArray<SJAssetItem *> *m = [NSMutableArray arrayWithCapacity:numberOfAssets]; | ||
for ( int i = 0 ; i < numberOfAssets ; ++ i ) { | ||
SJAssetItem *item = [SJAssetItem.alloc initWithIdx:i]; | ||
[m addObject:item]; | ||
} | ||
[self.listController addMedias:m]; | ||
|
||
if ( self.mPrivatePlaybackObserver.playbackDidFinishExeBlock == nil ) { | ||
self.mPrivatePlaybackObserver.playbackDidFinishExeBlock = ^(__kindof SJBaseVideoPlayer * _Nonnull player) { | ||
[player.listController currentMediaFinishedPlaying]; | ||
}; | ||
} | ||
} | ||
|
||
- (NSInteger)numberOfAssets { | ||
return self.listController.medias.count; | ||
} | ||
|
||
- (NSInteger)currentAssetIndex { | ||
return self.listController.currentMedia.id; | ||
} | ||
|
||
- (void)playPreviousAsset { | ||
[self.listController playPreviousMedia]; | ||
} | ||
|
||
- (void)playNextAsset { | ||
[self.listController playNextMedia]; | ||
} | ||
|
||
- (void)playAtIndex:(NSInteger)index { | ||
[self.listController playAtIndex:index]; | ||
} | ||
@end |
Oops, something went wrong.