views:

27

answers:

0

Hello, making a thumbnail from video using the picker is straight forward. However, when I press PLAY in the picker and then chose the video, my thumbnail is alway black. I was hoping it makes a screenshot - however this method only takes the first image of the video - and ONLY IF IT HASN'T BEEN PLAYED!

How can I make a thumbnail at any position of the video?

Here the "normal" code I use for thumbnails, where the video hasn't been played:

- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection {

    CGSize size = viewImage.size;
    CGFloat ratio = 0;
    if (size.width > size.height) {
        ratio = 80.0 / size.width;
    } else {
        ratio = 80.0 / size.height;
    }
    CGRect rectForthumbnail = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height);

    UIGraphicsBeginImageContext(rectForthumbnail.size);

    CGRect clipRect = CGRectMake(0.0, 0.0,74,74);
    [viewImage drawInRect:clipRect];
    dance.thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

After having pressed "PLAY", unfortunately, the created thumbnail is black (only shows the top of the iphone screen where the video roll and the current play position is displayed), the remaining of the thumbnail is always black. As said, in other cases it works well.

Thanks very much!