[英]Change volume of MPMusicPlayerController without changing system volume
My app has a feature to play system music player's music and it has it's own audio too. 我的应用程序具有播放系统音乐播放器的音乐的功能,它也具有自己的音频。 When music player's music is playing and app's audio will begin to play, I have to decrease the music player volume without affecting app's volume.
当播放音乐播放器的音乐并且开始播放应用程序的音频时,我必须在不影响应用程序音量的情况下减小音乐播放器的音量。
I am currently changing music player's volume with MPVolumeView
as MPMusicPlayerController
volume
property is deprecated. 我目前正在使用
MPVolumeView
更改音乐播放器的音量,因为不建议使用MPMusicPlayerController
volume
属性。 But it is system volume which affects app's volume too though I have used [avAudioPlayer setVolume:1.0]
, which is quite natural. 但是,即使我使用了
[avAudioPlayer setVolume:1.0]
,这也是影响应用程序音量的系统音量,这很自然。
My question is, is there any way to change the music player's volume without affecting app's volume? 我的问题是,有什么方法可以改变音乐播放器的音量而不影响应用程序的音量吗?
Yo can only change device volume with MPVolumeView
. 您只能使用
MPVolumeView
更改设备音量。 If you want to change application volume, there is AVAudioPlayer
. 如果要更改应用程序音量,请使用
AVAudioPlayer
。 It has volume
property, so you can change your volume that way. 它具有
volume
属性,因此您可以通过这种方式更改音量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.