2012-10-29 179 views
0

我一直在使用MPMoviePlayerController播放mp4文件。視頻播放正常,但根本沒有音頻。 我已經下載了第一個功能,並使用另一個功能。請檢查下面的代碼。我在做什麼錯在這裏...沒有使用MPMoviePlayerController播放的音頻

- (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]; 
     } 
    } 
} 

感謝您的幫助

回答

0

我有固定的問題。問題是.mp4擴展名,我用過.mov。它現在播放音頻。