AVQueuePlayer播放,但没有声音

- (void)playVideoInteractionNarration:(NSString *)vNarr{ [self pauseActionExecution]; NSURL *u = [NSURL fileURLWithPath:vNarr]; AVQueuePlayer *player = [[AVQueuePlayer alloc] initWithURL:u]; self.controller = [[AVPlayerViewController alloc]init]; controller.player = player; controller.showsPlaybackControls=NO; [controller.player setActionAtItemEnd:AVPlayerActionAtItemEndAdvance]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoNarrationFinishedPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:player.currentItem]; //NSLog(@"MPVIDEOOOOOOO %@", player); [controller.player setVolume:1.0]; [controller.player setMuted:NO]; [controller setViewInCurrentController]; [controller.player play]; } - (void)videoNarrationFinishedPlaying:(NSNotification *) aNotification{ AVPlayerItem * item = [aNotification object]; [self.controller removeViewInCurrentController]; [[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:item]; [self.controller.player pause]; [self.controller release]; [self playActionExecution]; } 

video开始和完成正确,但没有声音为什么?

 @import AVKit; @import AVFoundation; @property (nonatomic) AVPlayer *avPlayer; NSURL *fileURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"]; self.avPlayer = [AVPlayer playerWithURL:fileURL]; self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer]; videoLayer.frame = self.view.bounds; videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; [self.view.layer addSublayer:videoLayer]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:[self.avPlayer currentItem]]; [self.avPlayer play]; 

试试这个代码,并评论你的一个,并检查你的设备是否听起来工作?

正确的答案是这样的:

  [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];