Avplayerviewcontroller Using Audio-Only Avplayer

How to play Audio only in a video file in AVPlayer

Make your video player size 0x0 or place it outside of the screen.

AVPlayer audio only works when ringer is on

https://developer.apple.com/documentation/avfoundation/avplayer/1390127-volume

Turns out that the volume is set to 0.0 when ringer is in silent mode. By setting the volume to 1.0 by default, there is volume all the time.

Added this:

self.player?.volume = 1.0

inside of the child view below the videoGravity line

Video is not showing me use AVPlayer only audio is working

  1. I guess that the problem is in your video file. Try to download another video mp4 video sample. Add it to your project and try.

  2. You don't need this code:

    self.videoPlayer.view.frame = self.view.frame;   
    [self.view addSubview:self.videoPlayer.view];

Swift: Playing audio using AVPlayer - Audio is not playing, cannot hear audio

When using AVPlayer you should make sure your device is not on silent mode as that will cause to not output audio even though your volume is at max.

If you would like to keep your device on silent mode and still play the audio you can use the following code before your .play():

do {
try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [])
}
catch {
// report for an error
print(error)
}


Related Topics



Leave a reply



Submit