AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:movieURL];
CMTime duration = playerItem.duration; float seconds = CMTimeGetSeconds(duration);
NSLog(@"duration: %.2f", seconds);
This worked fine with iOS 6 but with iOS 7 for some reason it returns NaN. When inspecting playerItem.duration the CMTime object has 0's with a flag of 17.
But player works fine, just the duration is wrong.
So over come this problem Please import these frameworks.
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import <CoreMedia/CoreMedia.h>
#import <AVFoundation/AVAsset.h>
In place of above code you can paste this code:
AVURLAsset *asset = [AVURLAsset assetWithURL: movieURL];
Float64 duration = CMTimeGetSeconds(asset.duration);
NSLog(@"duration..%f", duration);
Thank u Frnd... Your code solved my big issue... thanks a lot...
ReplyDelete