2

我有一个 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];
4

1 回答 1

0

使用 AVFoundation 框架和 AVPlayer 类来播放视频文件。您可以自由地自定义外观、控件等。如果您不想要这些控件,您可以隐藏它们。

于 2012-12-19T10:32:03.430 回答