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.
问问题
1215 次
1 回答
1
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];
于 2013-02-25T03:25:40.083 回答