Created
December 3, 2021 07:39
-
-
Save megabayt/205b3e093e7c39e990458d4ae87cde3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AVURLAsset *textURLAsset; | |
NSString *textUri = [_textTracks objectAtIndex:i][@"uri"]; | |
if ([[textUri lowercaseString] hasPrefix:@"http"]) { | |
textURLAsset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:textUri] options:assetOptions]; | |
} else { | |
textURLAsset = [AVURLAsset URLAssetWithURL:[self urlFilePath:textUri] options:nil]; | |
} | |
[textURLAsset loadValuesAsynchronouslyForKeys:@[@"playable",@"tracks"] completionHandler:^{ | |
// Now tracks is available | |
NSLog(@" total tracks %@", textURLAsset.tracks); | |
NSError *error = nil; | |
AVKeyValueStatus status = | |
[textURLAsset statusOfValueForKey:@"tracks" error:&error]; | |
switch (status) { | |
case AVKeyValueStatusLoaded: | |
NSLog(@"AVKeyValueStatusLoaded"); | |
break; | |
case AVKeyValueStatusFailed: | |
NSLog(@"AVKeyValueStatusFailed"); | |
break; | |
case AVKeyValueStatusCancelled: | |
NSLog(@"AVKeyValueStatusCancelled"); | |
break; | |
default: | |
NSLog(@"default"); | |
break; | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment