iphoneobjective-cios6deprecatedcore-video

iOS 6: AVPlayerItem PresentationSize returning zero - (naturalSize method Deprecated on iOS 5)


Got this code:

videoSize = [[AVPlayerItem playerItemWithAsset:asset] presentationSize]; 

// nslogs -> height: 000 width 000

And this deprecated:

videoSize = [asset naturalSize];

// nslogs -> height: 360 width 480

Why is this happening? I don't get it.


Solution

  • Solved:

    NSArray* allVideoTracks = [movieAsset tracksWithMediaType:AVMediaTypeVideo];
    if ([allVideoTracks count] > 0) {
    AVAssetTrack* track = [[movieAsset tracksWithMediaType:AVMediaTypeVideo]objectAtIndex:0];
    CGSize size = [track naturalSize];
    }
    

    this made my day, hope it works for someone else...