Skip to content

Commit

Permalink
Fix export some problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Mar 14, 2018
1 parent 4d50114 commit adcdd2e
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 128 deletions.
6 changes: 3 additions & 3 deletions SJVideoPlayer/ControlView/SJFilmEditingResultShareItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ NS_ASSUME_NONNULL_BEGIN

@protocol SJFilmEditingResultShareDelegate <NSObject>

- (void)prepareToExport; // 准备导出, 可以做一些准备工作.
- (SJFilmEditingResultUploader *)prepareToExport; // 准备导出, 可以做一些准备工作.

- (SJFilmEditingResultUploader *)successfulScreenshot:(UIImage *)screenshot;
- (void)successfulScreenshot:(UIImage *)screenshot;

- (SJFilmEditingResultUploader *)successfulExportedVideo:(NSURL *)sandboxURL screenshot:(UIImage *)screenshot;
- (void)successfulExportedVideo:(NSURL *)sandboxURL screenshot:(UIImage *)screenshot;

- (void)clickedItem:(SJFilmEditingResultShareItem *)item;

Expand Down
1 change: 1 addition & 0 deletions SJVideoPlayer/ControlView/SJFilmEditingResultShareItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ - (instancetype)initWithTitle:(NSString *)title image:(UIImage *)image {
@end

@implementation SJFilmEditingResultUploader

@end
10 changes: 8 additions & 2 deletions SJVideoPlayer/ControlView/SJVideoPlayerFilmEditingControlView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ typedef NS_ENUM(NSUInteger, SJVideoPlayerFilmEditingViewTag) {
SJVideoPlayerFilmEditingViewTag_Export,
};

typedef NS_ENUM(NSUInteger, SJVideoPlayerFilmEditingRecrodStatus) {
SJVideoPlayerFilmEditingRecrodStatus_Unknown,
SJVideoPlayerFilmEditingRecrodStatus_Recording,
SJVideoPlayerFilmEditingRecrodStatus_Finished,
SJVideoPlayerFilmEditingRecrodStatus_Paused,
};

@interface SJVideoPlayerFilmEditingControlView : UIView

@property (nonatomic, strong, nullable) SJFilmEditingResultShare *resultShare;
Expand All @@ -31,8 +38,7 @@ typedef NS_ENUM(NSUInteger, SJVideoPlayerFilmEditingViewTag) {


#pragma mark - record
@property (nonatomic, readonly) BOOL isRecording;
@property (nonatomic, readonly) BOOL isPausedRecord;
@property (nonatomic, readonly) SJVideoPlayerFilmEditingRecrodStatus recordStatus;
- (void)pauseRecording;
- (void)resumeRecording;
- (void)completeRecording;
Expand Down
26 changes: 13 additions & 13 deletions SJVideoPlayer/ControlView/SJVideoPlayerFilmEditingControlView.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @interface SJVideoPlayerFilmEditingControlView ()
@property (nonatomic, strong, readonly) SJVideoPlayerFilmEditingRecordView *recordView;
@property (nonatomic, strong, readonly) UITapGestureRecognizer *tapGR;
@property (nonatomic, weak, readwrite) SJFilmEditingResultUploader *uploader;
@property (nonatomic, readwrite) SJVideoPlayerFilmEditingRecrodStatus recordStatus;

@end
NS_ASSUME_NONNULL_END
Expand Down Expand Up @@ -55,14 +56,13 @@ - (void)clickedBtn:(UIButton *)btn {
switch ( btn.tag ) {
// screenshot
case SJVideoPlayerFilmEditingViewTag_Screenshot: {
_isRecording = NO;
_recordStatus = SJVideoPlayerFilmEditingRecrodStatus_Unknown;
[self _showResultWithType:SJVideoPlayerFilmEditingResultViewType_Screenshot];
}
break;
// export
case SJVideoPlayerFilmEditingViewTag_Export: {
_isPausedRecord = NO;
_isRecording = YES;
_recordStatus = SJVideoPlayerFilmEditingRecrodStatus_Recording;
if ( _startRecordingExeBlock ) _startRecordingExeBlock(self);
self.recordView.tipsText = _recordTipsText;
_recordView.waitingForRecordingTipsText = _waitingForRecordingTipsText;
Expand All @@ -84,24 +84,24 @@ - (void)clickedBtn:(UIButton *)btn {
}

- (void)pauseRecording {
_isPausedRecord = YES;
_recordStatus = SJVideoPlayerFilmEditingRecrodStatus_Paused;
[_recordView pause];
}

- (void)resumeRecording {
_isPausedRecord = NO;
_recordStatus = SJVideoPlayerFilmEditingRecrodStatus_Recording;
[_recordView resume];
}

- (void)completeRecording {
_isPausedRecord = NO;
_recordStatus = SJVideoPlayerFilmEditingRecrodStatus_Finished;
[_recordView stop];
[self _showResultWithType:SJVideoPlayerFilmEditingResultViewType_Video];
}

- (void)_prepareToExport {
if ( [self.resultShare.delegate respondsToSelector:@selector(prepareToExport)] ) {
[self.resultShare.delegate prepareToExport];
self.uploader = [self.resultShare.delegate prepareToExport];
}
}

Expand All @@ -115,6 +115,8 @@ - (void)_showResultWithType:(SJVideoPlayerFilmEditingResultViewType)type{
_s_resultView.alpha = 0.001;
_s_resultView.image = self.getVideoScreenshot(self);
_s_resultView.items = self.resultShare.filmEditingResultShareItems;
_s_resultView.uploader = self.uploader;

__weak typeof(self) _self = self;
_s_resultView.clickedCancelBtnExeBlock = ^(SJVideoPlayerFilmEditingResultView * _Nonnull view) {
__strong typeof(_self) self = _self;
Expand Down Expand Up @@ -144,7 +146,7 @@ - (void)_showResultWithType:(SJVideoPlayerFilmEditingResultViewType)type{
if ( self.recordCompleteExeBlock ) self.recordCompleteExeBlock(self, _recordView.currentTime);
}
if ( type == SJVideoPlayerFilmEditingResultViewType_Screenshot && [_resultShare.delegate respondsToSelector:@selector(successfulScreenshot:)] ) {
self.uploader = [self.resultShare.delegate successfulScreenshot:_s_resultView.image];
[self.resultShare.delegate successfulScreenshot:_s_resultView.image];
}
}];
}];
Expand All @@ -171,6 +173,7 @@ - (float)recordedVideoExportProgress {
- (void)setExportFailed:(BOOL)exportFailed {
[_recordView stop];
_s_resultView.exportFailed = exportFailed;
self.uploader.failed = exportFailed;
}

- (BOOL)exportFailed {
Expand All @@ -180,7 +183,7 @@ - (BOOL)exportFailed {
- (void)setExportedVideoURL:(NSURL *)exportedVideoURL {
_exportedVideoURL = exportedVideoURL;
if ( [self.resultShare.delegate respondsToSelector:@selector(successfulExportedVideo:screenshot:)] ) {
self.uploader = [self.resultShare.delegate successfulExportedVideo:exportedVideoURL screenshot:self.s_resultView.image];
[self.resultShare.delegate successfulExportedVideo:exportedVideoURL screenshot:self.s_resultView.image];
}
}

Expand All @@ -199,13 +202,10 @@ - (void)handleTapGR {
}

- (void)setUploader:(SJFilmEditingResultUploader *)uploader {
_uploader = uploader;
_s_resultView.uploader = uploader;
}

- (SJFilmEditingResultUploader *)uploader {
return _s_resultView.uploader;
}

#pragma mark -
- (void)_setupViews {
[self addSubview:self.screenshotBtn];
Expand Down
13 changes: 0 additions & 13 deletions SJVideoPlayer/ControlView/SJVideoPlayerReachabilityPromptView.h

This file was deleted.

17 changes: 0 additions & 17 deletions SJVideoPlayer/ControlView/SJVideoPlayerReachabilityPromptView.m

This file was deleted.

50 changes: 32 additions & 18 deletions SJVideoPlayer/SJVideoPlayerDefaultControlView.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@

inline static void UIView_Animations(NSTimeInterval duration, Block __nullable animations, Block __nullable completion);

@interface _SJAnimationContext : NSObject
@property (nonatomic, copy, nullable) Block completion;
- (instancetype)initWithCompletion:(nullable Block)completion;
@end


#pragma mark -
@interface SJVideoPlayerDefaultControlView ()<SJVideoPlayerLeftControlViewDelegate, SJVideoPlayerBottomControlViewDelegate, SJVideoPlayerTopControlViewDelegate, SJVideoPlayerPreviewViewDelegate, SJVideoPlayerCenterControlViewDelegate, SJVideoPlayerRightControlViewDelegate>

Expand Down Expand Up @@ -93,13 +87,37 @@ - (instancetype)initWithFrame:(CGRect)frame {
[self _controlViewLoadSetting];
// default values
_generatePreviewImages = YES;
[self _controlViewInstallNotifications];
return self;
}

- (void)dealloc {
#ifdef DEBUG
NSLog(@"SJVideoPlayerLog: %zd - %s", __LINE__, __func__);
#endif
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)_controlViewInstallNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
}

- (void)applicationWillResignActive {
if ( _filmEditingControlView.recordStatus == SJVideoPlayerFilmEditingRecrodStatus_Recording ) {
[_filmEditingControlView pauseRecording];
[self.videoPlayer pauseForUser];
}
}

- (void)applicationDidBecomeActive {
if ( _filmEditingControlView.recordStatus == SJVideoPlayerFilmEditingRecrodStatus_Paused ) {
[_filmEditingControlView resumeRecording];
}
else if ( _filmEditingControlView.recordStatus == SJVideoPlayerFilmEditingRecrodStatus_Finished ) {
[self.videoPlayer pauseForUser];
}
}

#pragma mark - setup views
Expand Down Expand Up @@ -639,19 +657,10 @@ - (SJLoadingView *)loadingView {
#pragma mark - 加载配置

- (void)_controlViewLoadSetting {
// load setting
SJVideoPlayer.update(^(SJVideoPlayerSettings * _Nonnull commonSettings) {});

// load default setting
__weak typeof(self) _self = self;

SJVideoPlayer.update(^(SJVideoPlayerSettings * _Nonnull commonSettings) {
// update common settings
commonSettings.more_trackColor = [UIColor whiteColor];
commonSettings.progress_trackColor = [UIColor colorWithWhite:0.4 alpha:1];
commonSettings.progress_bufferColor = [UIColor whiteColor];
// .... other settings ....
// .... .... .... .... ....
});

self.settingRecroder = [[SJVideoPlayerControlSettingRecorder alloc] initWithSettings:^(SJVideoPlayerSettings * _Nonnull setting) {
__strong typeof(_self) self = _self;
if ( !self ) return;
Expand Down Expand Up @@ -771,7 +780,7 @@ - (void)videoPlayer:(SJVideoPlayer *)videoPlayer stateChanged:(SJVideoPlayerPlay
}

if ( SJVideoPlayerPlayState_PlayEnd == state ) {
if ( _filmEditingControlView && _filmEditingControlView.isRecording ) {
if ( _filmEditingControlView && _filmEditingControlView.recordStatus == SJVideoPlayerFilmEditingRecrodStatus_Recording ) {
[videoPlayer showTitle:self.settings.videoPlayDidToEndText duration:2];
[_filmEditingControlView completeRecording];
}
Expand Down Expand Up @@ -1001,6 +1010,11 @@ - (void)_promptWithNetworkStatus:(SJNetworkStatus)status {

#pragma mark - other

@interface _SJAnimationContext : NSObject
@property (nonatomic, copy, nullable) Block completion;
- (instancetype)initWithCompletion:(nullable Block)completion;
@end

@implementation _SJAnimationContext
- (instancetype)initWithCompletion:(nullable Block)completion {
self = [super init];
Expand Down
Binary file modified SJVideoPlayerProject/.DS_Store
Binary file not shown.
32 changes: 16 additions & 16 deletions SJVideoPlayerProject/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ PODS:
- Masonry (1.1.0)
- Reachability (3.2)
- SJAttributesFactory (2.0.2)
- SJBaseVideoPlayer (1.0.3.5):
- SJBaseVideoPlayer (1.0.3.8):
- Masonry
- Reachability
- SJBaseVideoPlayer/Category (= 1.0.3.5)
- SJBaseVideoPlayer/GestureControl (= 1.0.3.5)
- SJBaseVideoPlayer/Header (= 1.0.3.5)
- SJBaseVideoPlayer/Model (= 1.0.3.5)
- SJBaseVideoPlayer/Present (= 1.0.3.5)
- SJBaseVideoPlayer/Registrar (= 1.0.3.5)
- SJBaseVideoPlayer/TimerControl (= 1.0.3.5)
- SJBaseVideoPlayer/Category (= 1.0.3.8)
- SJBaseVideoPlayer/GestureControl (= 1.0.3.8)
- SJBaseVideoPlayer/Header (= 1.0.3.8)
- SJBaseVideoPlayer/Model (= 1.0.3.8)
- SJBaseVideoPlayer/Present (= 1.0.3.8)
- SJBaseVideoPlayer/Registrar (= 1.0.3.8)
- SJBaseVideoPlayer/TimerControl (= 1.0.3.8)
- SJBorderLineView
- SJFullscreenPopGesture
- SJObserverHelper
Expand All @@ -20,7 +20,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/Category (1.0.3.5):
- SJBaseVideoPlayer/Category (1.0.3.8):
- Masonry
- Reachability
- SJBorderLineView
Expand All @@ -31,7 +31,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/GestureControl (1.0.3.5):
- SJBaseVideoPlayer/GestureControl (1.0.3.8):
- Masonry
- Reachability
- SJBorderLineView
Expand All @@ -42,7 +42,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/Header (1.0.3.5):
- SJBaseVideoPlayer/Header (1.0.3.8):
- Masonry
- Reachability
- SJBorderLineView
Expand All @@ -53,7 +53,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/Model (1.0.3.5):
- SJBaseVideoPlayer/Model (1.0.3.8):
- Masonry
- Reachability
- SJBorderLineView
Expand All @@ -64,7 +64,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/Present (1.0.3.5):
- SJBaseVideoPlayer/Present (1.0.3.8):
- Masonry
- Reachability
- SJBaseVideoPlayer/Header
Expand All @@ -76,7 +76,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/Registrar (1.0.3.5):
- SJBaseVideoPlayer/Registrar (1.0.3.8):
- Masonry
- Reachability
- SJBorderLineView
Expand All @@ -87,7 +87,7 @@ PODS:
- SJUIFactory
- SJVideoPlayerAssetCarrier
- SJVolBrigControl
- SJBaseVideoPlayer/TimerControl (1.0.3.5):
- SJBaseVideoPlayer/TimerControl (1.0.3.8):
- Masonry
- Reachability
- SJBorderLineView
Expand Down Expand Up @@ -155,7 +155,7 @@ SPEC CHECKSUMS:
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
SJAttributesFactory: 01f680bab9e318b0bd11ddff58155a2c7475f2c3
SJBaseVideoPlayer: 88e92a4955f9ec60b071817213ad6ae9ae1d3028
SJBaseVideoPlayer: e6313ebbf4200194d364435f90fff8fb1a6f7a1a
SJBorderLineView: 5878e67fb57e812a2d5d029ca666068784b5448a
SJFullscreenPopGesture: cd46395d8487000b3c1b4fbac2c8747f34de7fc1
SJLabel: 159cd5eff4cc575390bf26316af634615218e3b7
Expand Down
Loading

0 comments on commit adcdd2e

Please sign in to comment.