2

我在尝试播放存储在 iOS 设备相机胶卷上的视频时遇到问题。

这是一个Adob​​e AIR应用程序,使用两个空气原生扩展 ( ANE ):

  • 一种用于选择媒体的扩展(来自图库的图像和视频)
  • 播放的另一个扩展MPMoviePlayerController

这是捕获的错误代码MPMoviePlayerPlaybackDidFinishNotification

Error: Error Domain=MediaPlayerErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x8a0a20 {NSLocalizedDescription=The operation could not be completed}

这是媒体选择器 ANE 的代码:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  if (self.popover) {
    [self.popover dismissPopoverAnimated:YES];
    self.popover = nil;
  } else {
    [picker dismissModalViewControllerAnimated:YES];
    picker = nil;
  }

  NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

  // Handle a movie
  if (CFStringCompare((CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo)
  {
    self.videoPath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
  }
}

// This function is called by the native extension to retrieve the path of the video.
DEFINE_ANE_FUNCTION(getVideoPath)
{
  NSLog(@"Entering getVideoPath");
  FREObject retValue = NULL;

  NSString *videoPath = [[AirImagePicker sharedInstance] videoPath];
  FRENewObjectFromUTF8(strlen([videoPath UTF8String])+1,
                     (const uint8_t *)[videoPath UTF8String],
                     &retValue);

  NSLog(@"Exiting getVideoPath");
  return retValue;
}

这是播放 ANE 的代码:

DEFINE_ANE_FUNCTION(loadVideo)
{
  uint32_t stringLength;

  NSString *path = nil;
  const uint8_t *urlString;
  if (FREGetObjectAsUTF8(argv[0], &stringLength, &urlString) == FRE_OK)
  {
    path = [NSString stringWithUTF8String:(const char *)urlString];
  }

  if (path)
  {
    [[[AirVideo sharedInstance] player] setContentURL:[NSURL fileURLWithPath:path]];
    [[[AirVideo sharedInstance] player] play];
  }

  return NULL;
}

DEFINE_ANE_FUNCTION(showPlayer)
{
  UIView *rootView = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view];
  [rootView addSubview:[[[AirVideo sharedInstance] player] view]];

  return nil;
}


- (MPMoviePlayerController *)player
{
    if (!_player)
    {
        // Initializer movie player
        _player = [[MPMoviePlayerController alloc] init];

        // Register for notifications
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:_player];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:_player];
    }

    return _player;
}

视频路径的跟踪显示了这一点:

/private/var/mobile/Applications/5912AED1-S1DE-25EF-A8B-EF7AD21E3R65/tmp//trim.‌​uUcGJU.MOV

任何帮助都感激不尽。

4

0 回答 0