本文介绍了在 iPhone 上获取当前系统音量级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法可以让我在 iPhone 上获得当前的系统音量级别?
Is there a way I can get the current system volume level on the iPhone?
我在想也许有一种方法可以制作 MPVolumeView
并从中获取价值.
I'm thinking maybe there's a way to make an MPVolumeView
and get the value from that.
推荐答案
musicPlayer = [[MPMusicPlayerController iPodMusicPlayer];
currentVolume = musicPlayer.volume;
从 iOS8.0 开始,这已被弃用,请尝试以下操作
This is now deprecated as of iOS8.0 so try the following
#import <AVFoundation/AVAudioSession.h>
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
CGFloat volume = audioSession.outputVolume;
这篇关于在 iPhone 上获取当前系统音量级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!