priore

Get duration of streaming

Nov 23rd, 2015
1,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // #import <AVFoundation/AVFoundation.h>
  2. NSTimeInterval duration = 0;
  3. NSURL url = [NSURL URLWithString:@"http://your-streaming-media-url";
  4. dispatch_queue_t queue = dispatch_queue_create("streaming.duration", NULL);
  5. dispatch_async(queue, ^{
  6.     AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:@{AVURLAssetPreferPreciseDurationAndTimingKey : @(YES)}];
  7.     if (asset) duration = CMTimeGetSeconds(asset.duration);
  8. });
Add Comment
Please, Sign In to add comment