tags:

views:

46

answers:

0

Hi Guys,

I got the thumbnail Image by passing the video url to the MPMoviePlayerController and I am playing the video by loading the Url string into the webview How can I set the Thumbnailimage as a thumnailwhen playing the video in webview at present I am getting white screen with play button.

My code is:

  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;


 }

Guys please give me suggestions to get out of this.

Hope I wil get quick response from your side.

Thanks all, Lakshmi.