I am trying to stream audio for an iPhone app. With the AVPlayer, I can stream audio from a URL with a few lines of code. I cannot change the volume with the AVPlayer though. Any help would be appreciated.
you can change volume by property volume, see below code
NSString* resourcePath = url; //your url
NSData *_objectData = [NSData dataWithContentsOfURL:[NSURL URLWithString:resourcePath]];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:_objectData error:&error];
audioPlayer.numberOfLoops = 0;
audioPlayer.volume = 5.0f; //set volume here
[audioPlayer prepareToPlay];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With