2014-09-05 4 views
3

Я пытаюсь создать расширение общего доступа для совместного использования видео с помощью новых расширений приложений iOS 8. Я хочу открыть приложение для фотографий и поделиться видео с помощью моего расширения.Как получить атрибуты видео в расширении общего доступа iOS8

Я получаю URL видео по следующим кодам:

NSExtensionItem *inputItem = self.extensionContext.inputItems.firstObject; 
    NSItemProvider *provider = inputItem.attachments[0]; 

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{ 

     if ([provider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeQuickTimeMovie]) 
     { 
      [provider loadItemForTypeIdentifier:@"com.apple.quicktime-movie" options:nil completionHandler:^(NSURL *path,NSError *error){ 
       if (path) 
       { 
        dispatch_async(dispatch_get_main_queue(), ^{ 
         _moviePath = path; 
        }); 
       } 
      }]; 
     } 
    }); 

Но я получил только видео файл URL:

file:///var/mobile/Media/DCIM/100APPLE/IMG_0062.MOV 

Я также хочу, чтобы получить больше видео атрибутов, таких как: размер и продолжительность

Я использовал следующие коды, но не работает:

NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]             forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; 
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:_moviePath options:opts]; 
int second = urlAsset.duration.value/urlAsset.duration.timescale; 

и этот код:

AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:_moviePath]; 
CMTime duration = playerItem.duration; 
float seconds = CMTimeGetSeconds(duration); 
NSLog(@"duration: %.2f", seconds); 

все они не работают

и Xcode советов:

Error [IRForTarget]: Call to a symbol-only function 'memset' that is not present in the target 
error: 0 errors parsing expression 
error: The expression could not be prepared to run in the target 

Вы можете помочь мне получить атрибуты видео спасибо?!

ответ

0

Теперь следующие коды действительно работают:

NSDictionary *opts = [NSDictionary 
    dictionaryWithObject:[NSNumber numberWithBool:NO] 
    forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; 

AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:_moviePath options:opts]; 
int second = urlAsset.duration.value/urlAsset.duration.timescale; 

И я не знаю, почему это не работает, прежде чем

+1

ли вам удалось найти ответ на этот вопрос!? я борюсь с этим сам – YuviGr

+0

у вас есть результат? –

Смежные вопросы