开发者

AVURLAsset loadValuesAsynchronouslyForKeys: completionHandler: never fires on device

I'm using next snippet to loadValues synchronously, so loading = NO never fires. An开发者_运维知识库d I have the same problem with AVAssetExportSession exportAsynchronously. It's all not working only on device.

NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:URL options:options];

NSArray *keys = [NSArray arrayWithObjects:@"duration", @"tracks", nil];

__block bool loading = YES;

[asset loadValuesAsynchronouslyForKeys:keys completionHandler:^(void) {
            loading = NO;
}];

while (loading)[[NSRunLoop currentRunLoop] runUntilDate:[[NSDate date] dateByAddingTimeInterval:0.5]];

Please, help! My brain is melting.


Here is the code I use:

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"intro" ofType:@"m4v"]];

    self.asset = [[AVURLAsset alloc] initWithURL:url options:nil];
    NSString *tracksKey = @"tracks";

    [self.asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:tracksKey] completionHandler:^{
// Other code here for AVPlayer
}];

I don't use any options or anything of that nature. I'm sure you've seen Apple's documentation example:

http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜