开发者

AVURLAsset's loadValuesAsynchronouslyForKeys method doesn't call completion block when executed in modal view controller

开发者 https://www.devze.com 2023-03-20 16:27 出处:网络
I\'m using AV Foundation to replay in-bundle .mov files. I followed Apple\'s guide to initiate an AVURLAsset instance and called its - (void)loadValuesAsynchronouslyForKeys:(NSArray *)keys completionH

I'm using AV Foundation to replay in-bundle .mov files. I followed Apple's guide to initiate an AVURLAsset instance and called its - (void)loadValuesAsynchronouslyForKeys:(NSArray *)keys completionHandler:(void (^)(void))handler method.

In the view controller loaded firstly, doing this works.

My app architecture adds modal view controllers on top of the base one, I found calling loadValuesAsynchronouslyForKeys in the following modal view controllers doesn't work well: the completion block handler has never got called.

I copy+paste the AV Foundation code shown below, so my thought is this code snippt doesn't work in modal view controllers, but why?

NSString *path = [[NSBundle mainBundle] pathForResource:@"video001" ofType:@"mov"];
NSURL *url = [NSURL fileURLWithPath:path isDirectory:NO];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
[asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObjects:@"tracks", nil] com开发者_高级运维pletionHandler:^(void){
    NSLog(@"compltion"); 
}];
0

精彩评论

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