[ASVideoNode] Addition of reset method to return to initial state (#2119)

* [ASVideoNode] Addition of reset method to allow video node to return to initial state of placeholder and play button

* Implemented pull request review comments for code style
This commit is contained in:
gazreese
2016-11-11 00:35:43 +00:00
committed by appleguy
parent 2ba8239ff5
commit 3cdbc63e31
4 changed files with 20 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)play;
- (void)pause;
- (BOOL)isPlaying;
- (void)resetToPlaceholder;
@property (nullable, nonatomic, strong, readwrite) AVAsset *asset;
/**

View File

@@ -671,6 +671,19 @@ static NSString * const kRate = @"rate";
return YES;
}
- (void)resetToPlaceholder
{
ASDN::MutexLocker l(__instanceLock__);
if (_playerNode != nil) {
[_playerNode removeFromSupernode];
_playerNode = nil;
}
[_player seekToTime:kCMTimeZero];
[self pause];
}
#pragma mark - Playback observers

View File

@@ -68,6 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)play;
- (void)pause;
- (BOOL)isPlaying;
- (void)resetToPlaceholder;
@end

View File

@@ -668,6 +668,11 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
return [_videoNode isPlaying];
}
- (void)resetToPlaceholder
{
[_videoNode resetToPlaceholder];
}
- (NSArray *)controlsForLayoutSpec
{
NSMutableArray *controls = [[NSMutableArray alloc] initWithCapacity:_cachedControls.count];