Get duration of streaming

priore Nov 23rd, 2015 (edited) 510 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. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand