[英]No audio played using MPMoviePlayerController
I have been using MPMoviePlayerController to play mp4 file. 我一直在使用MPMoviePlayerController播放mp4文件。 Video is playing fine but there is no audio at all. 视频播放正常,但完全没有音频。 I have downloaded first in one function and played using another. 我已经在一个功能中首先下载并使用了另一个功能。 Please check the code below. 请检查下面的代码。 Am I doing anything wrong here... 我在这里做错什么了吗...
- (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];
}
}
}
Thanks for your helps 谢谢你的帮助
I have fixed the issue. 我已经解决了这个问题。 Problem is with .mp4 extension, I have used .mov. 问题是.mp4扩展名,我用过.mov。 Its playing audio now. 现在正在播放音频。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.