ASVideoNode property proxy

This commit is contained in:
Erekle
2016-05-13 18:43:24 +04:00
parent 658d376d7b
commit 3e45f41710
2 changed files with 63 additions and 0 deletions

View File

@@ -33,6 +33,20 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL disableControls;
#pragma mark - ASVideoNode property proxy
/**
* When shouldAutoplay is set to true, a video node will play when it has both loaded and entered the "visible" interfaceState.
* If it leaves the visible interfaceState it will pause but will resume once it has returned.
*/
@property (nonatomic, assign, readwrite) BOOL shouldAutoplay;
@property (nonatomic, assign, readwrite) BOOL shouldAutorepeat;
@property (nonatomic, assign, readwrite) BOOL muted;
@property (nonatomic, assign, readonly) ASVideoNodePlayerState playerState;
//! Defaults to 100
@property (nonatomic, assign) int32_t periodicTimeObserverTimescale;
//! Defaults to AVLayerVideoGravityResizeAspect
@property (atomic) NSString *gravity;
- (instancetype)initWithUrl:(NSURL*)url;
- (instancetype)initWithAsset:(AVAsset*)asset;

View File

@@ -50,6 +50,12 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
CMTime _duration;
BOOL _disableControls;
BOOL _shouldAutoplay;
BOOL _shouldAutorepeat;
BOOL _muted;
int32_t _periodicTimeObserverTimescale;
NSString *_gravity;
}
@end
@@ -535,6 +541,49 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
}
}
- (void)setShouldAutoplay:(BOOL)shouldAutoplay
{
_shouldAutoplay = shouldAutoplay;
_videoNode.shouldAutoplay = _shouldAutoplay;
}
- (void)setShouldAutorepeat:(BOOL)shouldAutorepeat
{
_shouldAutorepeat = shouldAutorepeat;
_videoNode.shouldAutorepeat = YES;
}
- (void)setMuted:(BOOL)muted
{
_muted = muted;
_videoNode.muted = _muted;
}
- (void)setPeriodicTimeObserverTimescale:(int32_t)periodicTimeObserverTimescale
{
_periodicTimeObserverTimescale = periodicTimeObserverTimescale;
_videoNode.periodicTimeObserverTimescale = _periodicTimeObserverTimescale;
}
- (NSString*)gravity
{
if (_gravity == nil) {
_gravity = _videoNode.gravity;
}
return _gravity;
}
- (void)setGravity:(NSString *)gravity
{
_gravity = gravity;
_videoNode.gravity = _gravity;
}
- (ASVideoNodePlayerState)playerState
{
return _videoNode.playerState;
}
#pragma mark - Helpers
- (NSString *)timeStringForCMTime:(CMTime)time forTimeLabelType:(ASVideoPlayerNodeControlType)type
{