iOS7中的AVURLAsset持续时间为零

时间:2014-03-17 15:34:37

标签: objective-c ipad ios7 avurlasset

我正在尝试使用此代码在iPad上播放视频。对iOS 6来说没问题。但是,在iOS 7中,它的self.asset.duration.value为零。我想知道怎么做。

    NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
    NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];

    AVURLAsset *assetToCombine = [AVURLAsset URLAssetWithURL:url options:options];//original
    [assetToCombine retain];


    NSArray *requestedKey=[NSArray arrayWithObjects:@"duration", nil];
    [assetToCombine loadValuesAsynchronouslyForKeys:requestedKey completionHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            //do nth here

            NSLog(@"dispatch_async assetToCombine.duration.value is %lld.",assetToCombine.duration.value);

        });
    }];
    NSLog(@"assetToCombine.duration.value is %lld.",assetToCombine.duration.value);

0 个答案:

没有答案