在将视频网址字符串加载到webview中时,如何将从MpMoviePlayerController获取的缩略图设置为缩略图?

时间:2010-09-26 12:34:19

标签: objective-c

我通过将视频网址传递给MPMoviePlayerController来获取缩略图图片我通过将网址链接加载到网页视图中来播放视频如何在网络视图中播放视频时将Thumbnailimage设置为thumnail目前我正在变白带播放按钮的屏幕。

我的代码是:

  MPMoviePlayerController  *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:newURL];
    if (moviePlayer)
    {
        [moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
        [moviePlayer setFullscreen:YES];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDurationAvailableNotification:)
                                                     name:MPMovieDurationAvailableNotification
                                                   object:moviePlayer];
        moviePlayer.useApplicationAudioSession = NO;
        UIImage *image = [moviePlayer  thumbnailImageAtTime:(NSTimeInterval)1.0 timeOption: MPMovieTimeOptionNearestKeyFrame];
        NSData *imgData = UIImagePNGRepresentation(image);
        printf("\n length of ThumbnailImage Data...%d",[imgData length]);

        // May help to reduce latency
        //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification  object:moviePlayer];                           
        ///moviePlayer.view.frame = CGRectMake(184, 200, 400, 300);
        //[self.view addSubview:moviePlayer.view];

        //[moviePlayer play];

    }


 - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
printf("\n Inside didSelect method....!!");
masterAisleItemListIndexArray = (NSMutableArray*)[ [masterAisleItemListDictionary allKeys] sortedArrayUsingSelector:@selector(compare:)];
NSString* sectionName = [masterAisleItemListIndexArray objectAtIndex:indexPath.section];
NSMutableArray* aisleItemsArray = [masterAisleItemListDictionary valueForKey:sectionName];
CustomerDetails *custObj = [aisleItemsArray objectAtIndex:indexPath.row];
//CustomerDetails *custObj = [videosList objectAtIndex:indexPath.row];
printf("\n audiofile = %s",[custObj.audioFile UTF8String]);
//NSURL *URL = [NSURL URLWithString:custObj.audioFile];
    //printf("URL====%s",[URL UTF8String]);
    webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 440)];
    [myView addSubview:webView];
    webView.backgroundColor = [UIColor blueColor];
[webView loadHTMLString:[self getVideo:custObj.audioFile] baseURL:[NSURL URLWithString:@"http:bluepal.com"]];
    webView.delegate = self;
    self.view = myView;
    //[self downloadOutstandingFileSounds:custObj.audioFile];
 }


 -(NSString *)getVideo:(NSString *)aString
 {
NSString *htmlString = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 94\"/></head><body style=\"background:#000;margin-top:0px;margin-left:0px\"><div><object width=\"90\" height=\"70\"><embed src=\"";
htmlString = [htmlString stringByAppendingString:aString];
htmlString = [htmlString stringByAppendingString:@"\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"320\" height=\"400\"></embed></object></div></body></html>"];

printf("\n htmlString.......%s",[htmlString UTF8String]);
return htmlString;


 }

伙计们,请给我建议摆脱这个。

希望我能得到你方的快速反应。

谢谢大家, 拉克希米。

0 个答案:

没有答案