mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
[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:
@@ -39,6 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)play;
|
||||
- (void)pause;
|
||||
- (BOOL)isPlaying;
|
||||
- (void)resetToPlaceholder;
|
||||
|
||||
@property (nullable, nonatomic, strong, readwrite) AVAsset *asset;
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)play;
|
||||
- (void)pause;
|
||||
- (BOOL)isPlaying;
|
||||
- (void)resetToPlaceholder;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -668,6 +668,11 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
||||
return [_videoNode isPlaying];
|
||||
}
|
||||
|
||||
- (void)resetToPlaceholder
|
||||
{
|
||||
[_videoNode resetToPlaceholder];
|
||||
}
|
||||
|
||||
- (NSArray *)controlsForLayoutSpec
|
||||
{
|
||||
NSMutableArray *controls = [[NSMutableArray alloc] initWithCapacity:_cachedControls.count];
|
||||
|
||||
Reference in New Issue
Block a user