Iphone 使用MPMoviePlayerController无法播放音频
我一直在使用MPMoviePlayerController来播放mp4文件。视频播放正常,但根本没有音频。 我下载了一个函数中的first,并使用另一个函数进行了播放。请检查下面的代码。我做错什么了吗Iphone 使用MPMoviePlayerController无法播放音频,iphone,objective-c,ios,cocoa-touch,mpmovieplayercontroller,Iphone,Objective C,Ios,Cocoa Touch,Mpmovieplayercontroller,我一直在使用MPMoviePlayerController来播放mp4文件。视频播放正常,但根本没有音频。 我下载了一个函数中的first,并使用另一个函数进行了播放。请检查下面的代码。我做错什么了吗 - (void) download_file : (NSString *) msg_url { if (msg_url != nil) { // Download and play NSURL *url = [NSURL URLWithString:ms
- (void) download_file : (NSString *) msg_url
{
if (msg_url != nil) {
// Download and play
NSURL *url = [NSURL URLWithString:msg_url];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
char file_path[512] = {0};
get_app_data_path(OFI_VC_MAILBOX_PATH, file_path); // Give document path.
NSString *filePath = [NSString stringWithFormat:@"%s/%@", file_path,@"mailbox.mp4"];
[urlData writeToFile:filePath atomically:YES];
[self performSelectorOnMainThread:@selector(play_mp4_file:) withObject:filePath waitUntilDone:NO];
}
}
}
- (void) play_mp4_file : (NSString *) filepath
{
if (is_same_view == true) {
[self.view setUserInteractionEnabled:YES];
if (filepath != nil) {
NSURL *file_url = [NSURL fileURLWithPath:filepath];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:file_url];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
moviePlayer.useApplicationAudioSession = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
}
}
谢谢你的帮助我已经解决了这个问题。问题是.mp4扩展名,我使用了.mov。现在正在播放音频