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;
|
- (BOOL)isPlaying;
|
||||||
|
|
||||||
@property (nullable, nonatomic, strong, readwrite) AVAsset *asset;
|
@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) AVVideoComposition *videoComposition;
|
||||||
@property (nullable, nonatomic, strong, readwrite) AVAudioMix *audioMix;
|
@property (nullable, nonatomic, strong, readwrite) AVAudioMix *audioMix;
|
||||||
|
|
||||||
@@ -142,4 +143,4 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ static NSString * const kStatus = @"status";
|
|||||||
ASVideoNodePlayerState _playerState;
|
ASVideoNodePlayerState _playerState;
|
||||||
|
|
||||||
AVAsset *_asset;
|
AVAsset *_asset;
|
||||||
|
NSURL *_assetURL;
|
||||||
AVVideoComposition *_videoComposition;
|
AVVideoComposition *_videoComposition;
|
||||||
AVAudioMix *_audioMix;
|
AVAudioMix *_audioMix;
|
||||||
|
|
||||||
@@ -127,13 +128,10 @@ static NSString * const kStatus = @"status";
|
|||||||
ASDN::MutexLocker l(__instanceLock__);
|
ASDN::MutexLocker l(__instanceLock__);
|
||||||
|
|
||||||
AVPlayerItem *playerItem = nil;
|
AVPlayerItem *playerItem = nil;
|
||||||
if (_asset != nil) {
|
if (_assetURL != nil) {
|
||||||
if ([_asset isKindOfClass:[AVURLAsset class]] && [self hasURLAsset]) {
|
playerItem = [[AVPlayerItem alloc] initWithURL:_assetURL];
|
||||||
playerItem = [[AVPlayerItem alloc] initWithURL:((AVURLAsset *)_asset).URL];
|
} else if (_asset != nil) {
|
||||||
_asset = [playerItem asset];
|
playerItem = [[AVPlayerItem alloc] initWithAsset:_asset];
|
||||||
} else {
|
|
||||||
playerItem = [[AVPlayerItem alloc] initWithAsset:_asset];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerItem.videoComposition = _videoComposition;
|
playerItem.videoComposition = _videoComposition;
|
||||||
@@ -448,6 +446,34 @@ static NSString * const kStatus = @"status";
|
|||||||
_playerState = playerState;
|
_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
|
- (void)setAsset:(AVAsset *)asset
|
||||||
{
|
{
|
||||||
ASDN::MutexLocker l(__instanceLock__);
|
ASDN::MutexLocker l(__instanceLock__);
|
||||||
|
|||||||
Reference in New Issue
Block a user