#import <AVFoundation/AVFoundation.h>
+ (UIImage*) thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time { AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
NSParameterAssert(asset);
AVAssetImageGenerator *assetImageGenerator =[[AVAssetImageGenerator alloc] initWithAsset:asset];
assetImageGenerator.appliesPreferredTrackTransform = YES;
assetImageGenerator.apertureMode = AVAssetImageGeneratorApertureModeEncodedPixels;
CGImageRef thumbnailImageRef = NULL;
CFTimeInterval thumbnailImageTime = time;
NSError *thumbnailImageGenerationError = nil;
thumbnailImageRef = [assetImageGenerator copyCGImageAtTime:CMTimeMake(thumbnailImageTime, 60)actualTime:NULL error:&thumbnailImageGenerationError];
if(!thumbnailImageRef)
NSLog(@"thumbnailImageGenerationError %@",thumbnailImageGenerationError);
UIImage*thumbnailImage = thumbnailImageRef ? [[UIImage alloc]initWithCGImage: thumbnailImageRef] : nil;
return thumbnailImage;
}
-(void)setADvideoUrl:(NSString *)urlstr
{
urlstr = urlstr;
NSLog(@"%@",urlstr);
//http://v.qq.com/iframe/player.html?vid=k0511h0fvay&tiny=1&auto=0 大图
NSURL * url = [NSURLURLWithString:urlstr];
NSString * hostStr = [url host];
NSString * tXURL = @"v.qq.com";
//https://puui.qpic.cn/qqvideo_ori/0/k0511h0fvay_228_128/0 小图
NSString * videoPrewURL = nil;
if([tXURL isEqualToString:hostStr]){ //如果是腾讯视频
NSDictionary * dic = [urlstr getURLParameters];
NSString * videoIDStr = [dic objectForKey:@"vid"];
if(videoIDStr){
videoPrewURL = [NSStringstringWithFormat:@"https://puui.qpic.cn/qqvideo_ori/0/%@_228_128/0",videoIDStr];
NSLog(@"videoIDStr is %@",videoPrewURL);
}
}
}