我在 iphone 应用程序中播放音频,但问题是它在模拟器上运行良好,但在设备上不起作用这是我的代码,它只是在运行此代码时关闭应用程序。
NSString*thePath=[[NSBundle mainBundle] pathForResource:fileName ofType:@"MP3"];
NSURL*url=[NSURL fileURLWithPath:thePath];
//NSURL *url = [NSURL URLWithString:@"http://celeritas-solutions.com/pah_brd_v1/productivo/1.mp3"];
mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[mp moviePlayer] prepareToPlay];
[[mp moviePlayer] setUseApplicationAudioSession:NO];
[[mp moviePlayer] setShouldAutoplay:YES];
[[mp moviePlayer] setControlStyle:2];
[[mp moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
[self presentMoviePlayerViewControllerAnimated:mp];
这是视频代码,它也适用于模拟器,但不适用于 iphone
NSString*thePath=[[NSBundle mainBundle] pathForResource:fileName ofType:@"MP4"];
NSURL*url=[NSURL fileURLWithPath:thePath];
//NSURL *url = [NSURL URLWithString:@"http://celeritas-solutions.com/pah_brd_v1/productivo/1.mp4"];
mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[mp moviePlayer] prepareToPlay];
[[mp moviePlayer] setUseApplicationAudioSession:NO];
[[mp moviePlayer] setShouldAutoplay:YES];
[[mp moviePlayer] setControlStyle:2];
[[mp moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
[self presentMoviePlayerViewControllerAnimated:mp];