iPhone SDK - 静音
我有以下播放背景音乐的方法:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/bgMusic.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
bgMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
bgMusic.numberOfLoops = -1;
bgMusic.volume = 0.1;
if (bgMusic == nil)
NSLog([error description]);
else
[bgMusic play];
但是我怎样才能在任何视图中静音所有声音,而不仅仅是这个,任何声音?
谢谢。
I have the following to play m background music:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/bgMusic.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
bgMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
bgMusic.numberOfLoops = -1;
bgMusic.volume = 0.1;
if (bgMusic == nil)
NSLog([error description]);
else
[bgMusic play];
But how I can I in any view, mute all sounds, not just this, any sound?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[[MPMusicPlayerController applicationMusicPlayer] setVolume:(使用 0.0 到 1.0 之间的值)]
如果您的
MPMoviePlayerController
使用应用程序音频会话,则此方法有效。[[MPMusicPlayerController applicationMusicPlayer] setVolume:(use a value between 0.0 and 1.0)]
If your
MPMoviePlayerController
uses the application audio session, this works.