Objective-C Tips & Trick - Prioregroup.com
[Objective-C] Get duration of streaming
       
back

// #import <AVFoundation/AVFoundation.h>
NSTimeInterval duration = 0;
NSURL url = [NSURL URLWithString:@"http://your-streaming-media-url";
dispatch_queue_t queue = dispatch_queue_create("streaming.duration", NULL);
dispatch_async(queue, ^{
	AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:@{AVURLAssetPreferPreciseDurationAndTimingKey : @(YES)}];
	if (asset) duration = CMTimeGetSeconds(asset.duration);
});






Copyright © 1996-2018 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.
prioregroup.com