1

** 将视频 url 字符串加载到 web 视图时,如何将从 MpMoviePlayerController 获取的缩略图设置为缩略图?

并且此代码不在 iOS 7.0/Xcode 5.0 中使用?**

if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
    {
        NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

        //            NSData *webData = [NSData dataWithContentsOfURL:videoURL];

        MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
        UIImage  *thumbnail;
        thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionExact];

        //            NSLog(@"video : %@",webData);
        //            NSData *video = [[NSString alloc] initWithContentsOfURL:videoURL];
        //            [webData writeToFile:[self findUniqueMoviePath] atomically:YES];

        thumbnail = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        editButton.imageView.image=thumbnail;
        NSLog(@"%@",thumbnail);

        UIWebView *webViewAns = (UIWebView *)[scroll viewWithTag:20000+scroll_position];
        face1String = [webViewAns stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.documentElement.innerHTML"]];

        separate_array = [face1String componentsSeparatedByString:@"</font>"];

        NSString *imagepath_str = [[NSString alloc]init];

        imagepath_str = [NSString stringWithFormat:@"<img style=\"margin-left:10px;\" src=\"file://%@\"width=""100"" height=""100"" border=""3""></font>",thumbnail];

        image_str = [[NSString alloc]init];

        image_str = [NSString stringWithFormat:@"%@%@%@",[separate_array objectAtIndex:0],imagepath_str,[separate_array objectAtIndex:1]];

        [webViewAns loadHTMLString:[image_str description] baseURL:nil];

        face1String = image_str;

        [self dismissViewControllerAnimated:YES completion:nil];
        [self.popoverController dismissPopoverAnimated:YES];

    }
}

重播 :)

4

0 回答 0