Skip to content

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Mar 13, 2021
1 parent e641a03 commit af017ec
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 101 deletions.
Binary file modified Example/.DS_Store
Binary file not shown.
121 changes: 121 additions & 0 deletions Example/Pods/Local Podspecs/SJBaseVideoPlayer.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions Example/SJVideoPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
13FEB85DCAAE0D2C731299D6 /* libPods-SJVideoPlayer_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CCD2CA6C02217556CFBFA7AB /* libPods-SJVideoPlayer_Example.a */; };
3B070E8C25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B070E8B25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.m */; };
3B070EA225FC916300960506 /* SJFloatSmallViewTransitionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B070EA025FC916300960506 /* SJFloatSmallViewTransitionController.m */; };
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
Expand All @@ -28,7 +30,6 @@
7700905F24988F6900A99906 /* SJDYUserHomepageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7700905924988F6900A99906 /* SJDYUserHomepageViewController.m */; };
7700906024988F6900A99906 /* SJDYMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7700905B24988F6900A99906 /* SJDYMainViewController.m */; };
771BFDBB25AFE1EC0026C277 /* SJFloatModeDemoViewController1.m in Sources */ = {isa = PBXBuildFile; fileRef = 771BFDBA25AFE1EC0026C277 /* SJFloatModeDemoViewController1.m */; };
771BFDC025AFE2340026C277 /* SJFloatSmallViewTransitionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 771BFDBE25AFE2340026C277 /* SJFloatSmallViewTransitionController.m */; };
77357E462373DA3E00B81EE4 /* SJTestAliViewController3.m in Sources */ = {isa = PBXBuildFile; fileRef = 77357E442373DA3E00B81EE4 /* SJTestAliViewController3.m */; };
77357E472373DA3E00B81EE4 /* SJTestAliViewController3.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77357E452373DA3E00B81EE4 /* SJTestAliViewController3.xib */; };
77357E622375523C00B81EE4 /* SJSubtitlesTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77357E612375523C00B81EE4 /* SJSubtitlesTestViewController.m */; };
Expand Down Expand Up @@ -131,6 +132,10 @@

/* Begin PBXFileReference section */
0913D8D9BFC4EE68E3F1EF64 /* Pods-SJVideoPlayer_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SJVideoPlayer_Example.release.xcconfig"; path = "Target Support Files/Pods-SJVideoPlayer_Example/Pods-SJVideoPlayer_Example.release.xcconfig"; sourceTree = "<group>"; };
3B070E8A25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SJBaseVideoPlayer+ListPlaybackExtended.h"; sourceTree = "<group>"; };
3B070E8B25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SJBaseVideoPlayer+ListPlaybackExtended.m"; sourceTree = "<group>"; };
3B070EA025FC916300960506 /* SJFloatSmallViewTransitionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SJFloatSmallViewTransitionController.m; sourceTree = "<group>"; };
3B070EA125FC916300960506 /* SJFloatSmallViewTransitionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SJFloatSmallViewTransitionController.h; sourceTree = "<group>"; };
3DE6356926AEF70F060F33F3 /* SJVideoPlayer.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SJVideoPlayer.podspec; path = ../SJVideoPlayer.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
6003F58A195388D20070C39A /* 播放器.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "播放器.app"; sourceTree = BUILT_PRODUCTS_DIR; };
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -164,8 +169,6 @@
7700905B24988F6900A99906 /* SJDYMainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SJDYMainViewController.m; sourceTree = "<group>"; };
771BFDB925AFE1EC0026C277 /* SJFloatModeDemoViewController1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SJFloatModeDemoViewController1.h; sourceTree = "<group>"; };
771BFDBA25AFE1EC0026C277 /* SJFloatModeDemoViewController1.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SJFloatModeDemoViewController1.m; sourceTree = "<group>"; };
771BFDBE25AFE2340026C277 /* SJFloatSmallViewTransitionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SJFloatSmallViewTransitionController.m; sourceTree = "<group>"; };
771BFDBF25AFE2340026C277 /* SJFloatSmallViewTransitionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SJFloatSmallViewTransitionController.h; sourceTree = "<group>"; };
77357E432373DA3E00B81EE4 /* SJTestAliViewController3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SJTestAliViewController3.h; sourceTree = "<group>"; };
77357E442373DA3E00B81EE4 /* SJTestAliViewController3.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SJTestAliViewController3.m; sourceTree = "<group>"; };
77357E452373DA3E00B81EE4 /* SJTestAliViewController3.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SJTestAliViewController3.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -498,8 +501,8 @@
children = (
771BFDB925AFE1EC0026C277 /* SJFloatModeDemoViewController1.h */,
771BFDBA25AFE1EC0026C277 /* SJFloatModeDemoViewController1.m */,
771BFDBF25AFE2340026C277 /* SJFloatSmallViewTransitionController.h */,
771BFDBE25AFE2340026C277 /* SJFloatSmallViewTransitionController.m */,
3B070EA125FC916300960506 /* SJFloatSmallViewTransitionController.h */,
3B070EA025FC916300960506 /* SJFloatSmallViewTransitionController.m */,
);
path = 1;
sourceTree = "<group>";
Expand Down Expand Up @@ -838,6 +841,8 @@
A6C5D23322AC249800D63D1C /* SJRemoteCommandHandler.m */,
A6A2554122ABCE9200E42998 /* SJViewController1.h */,
A6A2554222ABCE9200E42998 /* SJViewController1.m */,
3B070E8A25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.h */,
3B070E8B25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.m */,
A6A2554322ABCE9200E42998 /* SJViewController1.xib */,
A6A2555422ABD00200E42998 /* Core */,
);
Expand Down Expand Up @@ -1138,8 +1143,10 @@
A6C5D23422AC249800D63D1C /* SJRemoteCommandHandler.m in Sources */,
77357E622375523C00B81EE4 /* SJSubtitlesTestViewController.m in Sources */,
7784A7FA237D3860000BA67E /* SJBarrageTestViewController.m in Sources */,
3B070EA225FC916300960506 /* SJFloatSmallViewTransitionController.m in Sources */,
77788FDF22C36CF300E26599 /* SJRecommendVideosTableViewCell.m in Sources */,
771BFDBB25AFE1EC0026C277 /* SJFloatModeDemoViewController1.m in Sources */,
3B070E8C25FC88C300960506 /* SJBaseVideoPlayer+ListPlaybackExtended.m in Sources */,
A65FE539248A891700A5D4A6 /* SJKeyboardDemoViewController1.m in Sources */,
774AF08722DC790D005FE462 /* SJView.m in Sources */,
77391C46246801D100443844 /* SJExtendedMediaCollectionViewModel.m in Sources */,
Expand All @@ -1149,7 +1156,6 @@
77391C292467DFA500443844 /* SJTopView.m in Sources */,
7756F58522E173D400F9DC7D /* SJTestViewController.m in Sources */,
77391C1A2467D62200443844 /* SJUITableViewDemoViewController3.m in Sources */,
771BFDC025AFE2340026C277 /* SJFloatSmallViewTransitionController.m in Sources */,
77391C1D2467D6EF00443844 /* SJUITableViewDemoViewController4.m in Sources */,
77391C382467F01500443844 /* SJUICollectionViewDemoViewController4.m in Sources */,
A6A2562622AC1C3500E42998 /* SJViewController5.m in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@
uuid = "4AC450A5-5FFE-40B1-BE68-399D3F02D8DE"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "99E2A66D-64E7-48DB-B3C1-98875B6C06FC"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
breakpointStackSelectionBehavior = "1"
scope = "1"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file not shown.
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
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
Loading

0 comments on commit af017ec

Please sign in to comment.