2012-02-06 76 views
0

下面是我设置mpmoviecontroller的代码。尽管我可以听到视频的声音,但我看不到视频的图片。我通过互联网搜索,但我找不到我的代码错误。有人能帮我摆脱这个困境吗?mpmovieviewcontroller无法在iPad应用程序中工作?

(注意,路径和URL是正确的〜:))

- (IBAction)playClicked:(id)sender { 
NSString *path=[[NSBundle mainBundle] bundlePath]; 
path=[path stringByAppendingPathComponent:@"movies.bundle"]; 
path=[path stringByAppendingPathComponent:@"mean.mp4"]; 

NSURL *url=[NSURL fileURLWithPath:path]; 
NSFileManager *filemanager=[NSFileManager defaultManager]; 

if([filemanager fileExistsAtPath:path]){ 
    NSLog(@"File exists at %@! You should be able to see the movie!:)",path); 
    MPMoviePlayerController *player=[[MPMoviePlayerController alloc] initWithContentURL:url]; 
    if(player){ 
     player.scalingMode = MPMovieScalingModeNone; 
     player.controlStyle=MPMovieControlStyleFullscreen; 
     player.movieSourceType=MPMovieSourceTypeFile; 
     [player.view setFrame:CGRectMake(0, navigationBar.bounds.size.height, self.view.bounds.size.width, self.view.bounds.size.height-navigationBar.bounds.size.height)]; 
     [self.view addSubview:player.view]; 
     [player prepareToPlay]; 
     NSLog(@"Ready to play for %@!",player.duration); 
     [player play]; 
     NSLog(@"Played!"); 
    } 
}else{ 
    NSLog(@"File does not exist!:("); 
} 

}

运行时错误:

2012-02-06 08:54:40.248 Board[1604:11f03] File exists at /Users/admin/Library/Application Support/iPhone Simulator/5.0/Applications/C468351E-3150-4397-B73A-8505D099B2C5/Board.app/movies.bundle/mean.mp4! You should be able to see the movie!:) 
    2012-02-06 08:54:40.276 Board[1604:11f03] Ready to play for (null)! 
    2012-02-06 08:54:40.277 Board[1604:11f03] Played! 
    [Switching to process 1604 thread 0x13e03] 
    [Switching to process 1604 thread 0x11f03] 
    2012-02-06 08:54:40.733 Board[1604:11f03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.740 Board[1604:11f03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.886 Board[1604:11f03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.894 Board[1604:11f03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.905 Board[1604:11f03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.928 Board[1604:11f03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.940 Board[1604:11f03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 
    2012-02-06 08:54:40.947 Board[1604:11f03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable 
    Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security 
    Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 
    in /System/Library/Frameworks/Security.framework/Versions/A/Security 

回答

0

看来,添加以下代码,将尽工作。

player.movieSourceType=MPMovieSourceTypeFile; 
[self.view addSubview:player.view]; 
[player setFullscreen:YES]; 
相关问题