AVQueuePlayer play but no sound

后端 未结 2 641
半阙折子戏
半阙折子戏 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 ?

提交回复
热议问题