mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
removed play button
* Removed play button from ASVideoNode * Removed play button tests * added some checks in ASVideoPlayerNode * added new delegate method for time formats
This commit is contained in:
@@ -63,8 +63,7 @@ static NSString * const kStatus = @"status";
|
||||
CMTime _timeObserverInterval;
|
||||
|
||||
ASImageNode *_placeholderImageNode; // TODO: Make ASVideoNode an ASImageNode subclass; remove this.
|
||||
|
||||
ASButtonNode *_playButtonNode;
|
||||
|
||||
ASDisplayNode *_playerNode;
|
||||
ASDisplayNode *_spinnerNode;
|
||||
NSString *_gravity;
|
||||
@@ -83,8 +82,7 @@ static NSString * const kStatus = @"status";
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.playButton = [[ASDefaultPlayButton alloc] init];
|
||||
|
||||
self.gravity = AVLayerVideoGravityResizeAspect;
|
||||
_periodicTimeObserverTimescale = 10000;
|
||||
[self addTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
@@ -201,10 +199,7 @@ static NSString * const kStatus = @"status";
|
||||
|
||||
// Stretch out play button, placeholder image player node to the max size
|
||||
NSMutableArray *children = [NSMutableArray array];
|
||||
if (_playButtonNode) {
|
||||
_playButtonNode.preferredFrameSize = maxSize;
|
||||
[children addObject:_playButtonNode];
|
||||
}
|
||||
|
||||
if (_placeholderImageNode) {
|
||||
_placeholderImageNode.preferredFrameSize = maxSize;
|
||||
[children addObject:_placeholderImageNode];
|
||||
@@ -224,18 +219,6 @@ static NSString * const kStatus = @"status";
|
||||
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:children];
|
||||
}
|
||||
|
||||
- (void)layout
|
||||
{
|
||||
[super layout];
|
||||
|
||||
CGRect bounds = self.bounds;
|
||||
|
||||
ASDN::MutexLocker l(_videoLock);
|
||||
CGFloat horizontalDiff = (CGRectGetWidth(bounds) - CGRectGetWidth(_playButtonNode.bounds))/2;
|
||||
CGFloat verticalDiff = (CGRectGetHeight(bounds) - CGRectGetHeight(_playButtonNode.bounds))/2;
|
||||
_playButtonNode.hitTestSlop = UIEdgeInsetsMake(-verticalDiff, -horizontalDiff, -verticalDiff, -horizontalDiff);
|
||||
}
|
||||
|
||||
- (void)generatePlaceholderImage
|
||||
{
|
||||
ASVideoNode * __weak weakSelf = self;
|
||||
@@ -421,26 +404,6 @@ static NSString * const kStatus = @"status";
|
||||
_playerState = playerState;
|
||||
}
|
||||
|
||||
- (void)setPlayButton:(ASButtonNode *)playButton
|
||||
{
|
||||
ASDN::MutexLocker l(_videoLock);
|
||||
|
||||
[_playButtonNode removeTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
[_playButtonNode removeFromSupernode];
|
||||
|
||||
_playButtonNode = playButton;
|
||||
[_playButtonNode addTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
|
||||
[self addSubnode:playButton];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (ASButtonNode *)playButton
|
||||
{
|
||||
ASDN::MutexLocker l(_videoLock);
|
||||
return _playButtonNode;
|
||||
}
|
||||
|
||||
- (void)setAsset:(AVAsset *)asset
|
||||
{
|
||||
ASDN::MutexLocker l(_videoLock);
|
||||
@@ -537,11 +500,8 @@ static NSString * const kStatus = @"status";
|
||||
if (_playerNode == nil) {
|
||||
_playerNode = [self constructPlayerNode];
|
||||
|
||||
if (_playButtonNode.supernode == self) {
|
||||
[self insertSubnode:_playerNode belowSubnode:_playButtonNode];
|
||||
} else {
|
||||
[self addSubnode:_playerNode];
|
||||
}
|
||||
[self addSubnode:_playerNode];
|
||||
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
@@ -549,10 +509,7 @@ static NSString * const kStatus = @"status";
|
||||
|
||||
[_player play];
|
||||
_shouldBePlaying = YES;
|
||||
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
_playButtonNode.alpha = 0.0;
|
||||
}];
|
||||
|
||||
if (![self ready]) {
|
||||
[self showSpinner];
|
||||
} else {
|
||||
@@ -605,9 +562,6 @@ static NSString * const kStatus = @"status";
|
||||
[_player pause];
|
||||
[self removeSpinner];
|
||||
_shouldBePlaying = NO;
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
_playButtonNode.alpha = 1.0;
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)isPlaying
|
||||
@@ -733,7 +687,6 @@ static NSString * const kStatus = @"status";
|
||||
{
|
||||
[_player removeTimeObserver:_timeObserver];
|
||||
_timeObserver = nil;
|
||||
[_playButtonNode removeTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
[self removePlayerItemObservers:_currentPlayerItem];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user