0

私は特定のプラットフォームにビデオ ファイルをアップロードするための iPhone アプリケーションに取り組んでいます。私が本当に気に入っている機能の 1 つは、ユーザーが選択できる同じビデオに対して、たとえば 10 個の異なるサムネイルを表示できるようにすることです。

問題は、ALAssetがデフォルトのサムネイルを返すだけのサムネイルメソッドしか提供しないことです。ALAssetRepresentation と ALAsset のドキュメントを読みましたが、特定のタイムスタンプのサムネイルを取得する方法が見つからないようです。

libav のラインに沿って何かを使用してサムネイルを取得することも 1 つのオプションだと思いますが、このようなものには少し「やりすぎ」のようです。誰でもこれで私を助けることができますか?

よろしく、
ニック

4

2 に答える 2

4

私はこれがあなたを助けると思います、そしてあなたはまたこのプロンプトを通して見ることができます ビデオファイルのサムネイルのタイムスタンプがALAssetにありません

{

  if ([theAsset valueForProperty:ALAssetPropertyType] == ALAssetTypeVideo) {

        // Black semi-transparent background at the bottom of the item
        CGRect containerFrame = CGRectMake(0, frame.size.height - AGIPC_ITEM_HEIGHT, frame.size.width, AGIPC_ITEM_HEIGHT);
        UIView *containerForMovieInfo = [[[UIView alloc] initWithFrame:containerFrame] autorelease];
        containerForMovieInfo.backgroundColor = [UIColor blackColor];
        containerForMovieInfo.alpha = 0.7f;

        // Movie icon on left side
        CGRect movieFrame = CGRectMake(4, 60, 26, 15);
        UIImageView *movieImageView = [[[UIImageView alloc] initWithFrame:movieFrame] autorelease];
        if (IS_IPAD()) {
            movieImageView.image = [UIImage imageNamed:@"AGIPC-Movie-iPad"];
        } else {
            movieImageView.image = [UIImage imageNamed:@"AGIPC-Movie-iPhone"];
        }
        [containerForMovieInfo addSubview:movieImageView];

        // Movie duration on right side
        if ([theAsset valueForProperty:ALAssetPropertyDuration] != ALErrorInvalidProperty) {
            NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
            [formatter setDateFormat:@"mm:ss"];
            CGRect durationFrame = CGRectMake(frame.size.width - 26 - 4, 60, 26, 15);
            UILabel *durationView = [[[UILabel alloc] initWithFrame:durationFrame] autorelease];
            durationView.backgroundColor = [UIColor clearColor];
            durationView.textColor = [UIColor whiteColor];
            durationView.text = [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[theAsset valueForProperty:ALAssetPropertyDuration] doubleValue]]];
            durationView.font = [UIFont systemFontOfSize:10];
            [containerForMovieInfo addSubview:durationView];
        }

        [self addSubview:containerForMovieInfo];
    }

}

最後に、カメラの画像を自分で作成する必要があります。

于 2012-08-20T14:23:53.847 に答える