mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Adding the new ASVideoNode API that allows for video player item construction with URL
This commit is contained in:
@@ -41,6 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (BOOL)isPlaying;
|
||||
|
||||
@property (nullable, nonatomic, strong, readwrite) AVAsset *asset;
|
||||
@property (nullable, atomic, strong, readwrite) NSURL *assetURL;
|
||||
@property (nullable, nonatomic, strong, readwrite) AVVideoComposition *videoComposition;
|
||||
@property (nullable, nonatomic, strong, readwrite) AVAudioMix *audioMix;
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ static NSString * const kStatus = @"status";
|
||||
ASVideoNodePlayerState _playerState;
|
||||
|
||||
AVAsset *_asset;
|
||||
NSURL *_assetURL;
|
||||
AVVideoComposition *_videoComposition;
|
||||
AVAudioMix *_audioMix;
|
||||
|
||||
@@ -127,14 +128,11 @@ static NSString * const kStatus = @"status";
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
AVPlayerItem *playerItem = nil;
|
||||
if (_asset != nil) {
|
||||
if ([_asset isKindOfClass:[AVURLAsset class]] && [self hasURLAsset]) {
|
||||
playerItem = [[AVPlayerItem alloc] initWithURL:((AVURLAsset *)_asset).URL];
|
||||
_asset = [playerItem asset];
|
||||
} else {
|
||||
if (_assetURL != nil) {
|
||||
playerItem = [[AVPlayerItem alloc] initWithURL:_assetURL];
|
||||
} else if (_asset != nil) {
|
||||
playerItem = [[AVPlayerItem alloc] initWithAsset:_asset];
|
||||
}
|
||||
}
|
||||
|
||||
playerItem.videoComposition = _videoComposition;
|
||||
playerItem.audioMix = _audioMix;
|
||||
@@ -448,6 +446,34 @@ static NSString * const kStatus = @"status";
|
||||
_playerState = playerState;
|
||||
}
|
||||
|
||||
- (void)setAssetURL:(NSURL *)assetURL
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
if ([_asset isKindOfClass:[AVURLAsset class]]) {
|
||||
if (ASObjectIsEqual(assetURL, ((AVURLAsset *)_asset).URL)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[self clearFetchedData];
|
||||
|
||||
_asset = [AVURLAsset assetWithURL:assetURL];
|
||||
|
||||
[self setNeedsDataFetch];
|
||||
}
|
||||
|
||||
- (NSURL *)assetURL
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
if ([_asset isKindOfClass:AVURLAsset.class]) {
|
||||
return ((AVURLAsset *)_asset).URL;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setAsset:(AVAsset *)asset
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
Reference in New Issue
Block a user