every one i am trying to get the video frame or thumbnail from a video url but not succeeding in it, here is my code
- (void)viewDidLoad {
thumbnailimg = [[UIImageView alloc]init];
movie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=ec9KXrpYvzk"]];
//UIImage *singleFrameImage = [movie thumbnailImageAtTime:10
//timeOption:MPMovieTimeOptionExact];
//thumbnailimg.image = singleFrameImage;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(handleThumbnailImageRequestFinishNotification:)
name:MPMoviePlayerThumbnailImageRequestDidFinishNotification
object:movie];
NSNumber * time =[NSNumber numberWithInt:10];
NSArray *times = [NSArray arrayWithObjects:time,nil];
[movie requestThumbnailImagesAtTimes:times timeOption:MPMovieTimeOptionExact];
[super viewDidLoad];
}
-(void)handleThumbnailImageRequestFinishNotification:(NSNotification*)note
{
NSDictionary *userinfo = [note userInfo];
NSMutableDictionary *event = [NSMutableDictionary dictionary];
NSError* value = [userinfo objectForKey:MPMoviePlayerThumbnailErrorKey];
if (value!=nil)
{
[event setObject:[value description] forKey:@"error"];
}
else
{
UIImage *image = [userinfo valueForKey:MPMoviePlayerThumbnailImageKey];
thumbnailimg.image = image;
}
[event setObject:[userinfo valueForKey:MPMoviePlayerThumbnailTimeKey] forKey:@"time"];
}
even the handleThumbnailImageRequestFinishNotification is not firing, plz. tell me what i am doing wrong and how to correct it, thanx in advance, Regards Saad