iPhone SDK - 静音

发布于 2024-09-18 07:02:58 字数 478 浏览 16 评论 0原文

我有以下播放背景音乐的方法:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情废物 2024-09-25 07:02:58

[[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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文