MPMoviePlayerController thumbnailImageAtTime:timeOption: simple case doesn't work
I build the movie player like this ...
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; player.view.frame = myView.bounds; player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [player prepareToPlay]; [myView addSubview:player.view]; self.mp = player;
The url points to an m3u8 web stream. It plays just fine. Then I ask for an image like this ...
NSTimeInterval currentInterval = self.mp.currentPlaybackTime; UIImage *image = [self.mp thumbnailImageAtTime:currentInterval timeOption:MPMovieTimeOptionExact];
I've tried backing the currentInterval up by one second. I've tried both time options (exact and keyframe), but image is always nil. Any idea why? Thanks.
My understanding is that the MPMoviePlayerController thumbnail methods don't work for HTTP Live Streaming (HLS) streams; only for files. Unfortunately I can't find an authoritative reference for that, although I saw, or read, it somewhere in the last couple of weeks. I've also had the same experience, myself.
That said, it might be possible to generate thumbnails for an HLS stream using AVAssetImageGenerator.
I've just tested AVAssetImageGenerator against a regular HTTP file, and the same file accessed over HLS. It was able to generate a thumbnail from the HTTP one, but the for the HLS one, AVAssetImageGenerator returned the following error:
NSLocalizedFailureReason=The operation is not supported for this media.
So, in summary, it looks as though HTTP Live Streaming doesn't support creating thumbnails. If your situation allows, you may be able to generate thumbnails on the server, make them available as a web service, then request them from the server in the client.