我在尝试播放存储在iOS设备相机胶卷上的视频时遇到问题。
这是一个 Adobe 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
非常感谢任何帮助。