我有一个 480p MOV 文件,它在 UiImageView 中看起来很棒(质量明智)。但是,它在播放时似乎会丢失帧率。有没有更好的方法在没有控件的情况下播放这部电影?它需要像 UI 上的动画一样播放。
提前致谢!
这是我的代码:
-(void)imagesExtractionThread {
NSDate * now = [[NSDate alloc] init];
startTime = [now timeIntervalSinceReferenceDate];
do{
[self performSelectorOnMainThread:@selector(setImageToAvatar) withObject:nil waitUntilDone:YES];
usleep(9000);
}while(!closing);}
-(void)setImageToAvatar{
NSDate * now = [[NSDate alloc] init];
NSTimeInterval curTime = [now timeIntervalSinceReferenceDate];
currentTime = curTime - startTime;
if(currentTime>player.playableDuration){
NSLog(@"Current time %lf",currentTime);
currentTime = 0.0;
startTime = curTime;
if(player.playableDuration >0){
closing = YES;
avatar.hidden = YES;
}
}
UIImage *singleFrameImage = [player thumbnailImageAtTime:currentTime
timeOption:1];
//singleFrameImage = [self changeGreenColorWithTransparent:singleFrameImage];
//
/*sourcePicture = [[GPUImagePicture alloc] initWithImage:singleFrameImage smoothlyScaleOutput:YES];
[sourcePicture addTarget:filter];
[sourcePicture processImage];
singleFrameImage = [filter imageFromCurrentlyProcessedOutput];*/
avatar.image = singleFrameImage;}
我使用以下代码开始播放过程:
player = [[MPMoviePlayerController alloc] initWithContentURL: url];
player.shouldAutoplay = NO;
[NSThread detachNewThreadSelector:@selector(imagesExtractionThread) toTarget:self withObject:nil];