** ビデオ 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];
}
}
リプレイ:)