AVQueuePlayer play but no sound

后端 未结 2 638
半阙折子戏
半阙折子戏 2021-01-26 11:45
- (void)playVideoInteractionNarration:(NSString *)vNarr{

[self pauseActionExecution];

NSURL *u = [NSURL fileURLWithPath:vNarr];
AVQueuePlayer *player = [[AVQueuePlayer         


        
相关标签:
2条回答
  • 2021-01-26 12:30
    @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];
    

    Try this code and comment your one and check that in your device did sound work or not ?

    0 讨论(0)
  • 2021-01-26 12:36

    the right answer is this:

      [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    
    0 讨论(0)
提交回复
热议问题