AVURLAsset refuses to load video

后端 未结 3 871
情歌与酒
情歌与酒 2020-11-30 04:47

I\'m trying to load a video file into my iPad app as an AVURLAsset, using the asynchronous-loading stuff to wait for it to be ready. Problem is, when I run it,

相关标签:
3条回答
  • 2020-11-30 04:56

    If you are using -[NSURL fileURLWithPath:] to create the URL and still get the same error.

    Check the AVURLAssetReferenceRestrictionsKey, Your local m3u8 may failed to play if it contains remote resource.

    Set the value to @(AVAssetReferenceRestrictionForbidNone) should solve the problem.

    0 讨论(0)
  • 2020-11-30 05:01

    If anyone is still having issues with this even after using fileURLWithPath, try requesting NSTimeIntervals in the time array if you are using int(s).

    This does not work:

        NSMutableArray *playbackTimes = [NSMutableArray array];
        for (int i = 0; i <= 10; i ++) {
            [playbackTimes addObject:@(i)];
        }
    
        [self.videoPlayer requestThumbnailImagesAtTimes:playbackTimes timeOption:MPMovieTimeOptionNearestKeyFrame];
    

    This works:

        NSMutableArray *playbackTimes = [NSMutableArray array];
        for (int i = 0; i <= 10; i ++) {
             [playbackTimes addObject:@((NSTimeInterval)i)];
         }
    
         [self.videoPlayer requestThumbnailImagesAtTimes:playbackTimes timeOption:MPMovieTimeOptionNearestKeyFrame];
    
    0 讨论(0)
  • 2020-11-30 05:16

    Solved. The trick: use fileURLWithPath:, not URLWithString:. Apparently the difference is really, really significant.

    0 讨论(0)
提交回复
热议问题