在应用程序内锁定 iPhone 真实音量

发布于 2024-12-04 13:53:42 字数 264 浏览 0 评论 0原文

我在应用程序商店中有一个闹钟应用程序,想要对其进行设置,以便用户在闹钟响起时无法降低音量(使用侧面按钮)。我在文档中找不到如何执行此操作,我错过了什么吗?

iHandySoft Inc. 的 Alarm Clock Free(流行的绿色闹钟)做到了这一点,使之成为可能。如果您同时降低主控和主控。将铃声音量设置为 0 并将 iPhone 设置为静音,闹钟仍会全力播放。然后你会发现你的主音量已经恢复到80%左右了。

我目前正在使用 AV 音频。

非常感谢所有帮助!

I have an alarm app in the appStore and want to set it up so that the user can NOT lower the volume(using side buttons) while the alarm is sounding. I cant find how to do this in the documentation, did I miss something?

Alarm Clock Free(the popular green one) by iHandySoft Inc. does it so it's possible. If you lower both the master & ringer volume to 0 and set the iphone on silent the alarm will still play full blast. Then you will find that your master volume has been raised back up to like 80%.

I am currently using AV Audio.

All help is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

乱了心跳 2024-12-11 13:53:42

我刚刚想出了这个。

我创建了一个循环并使用 MPMusicPlayerController 每十分之一秒将音量恢复到最大。

循环功能:

-(void) OverideVolumeLevelLoop:(NSTimer *)timer 
{ 
    [[MPMusicPlayerController applicationMusicPlayer] setVolume:1.0f]; 
}

然后只需 NSTimer 循环此功能:(

NSTimer *overideVolumeLoop = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(OverideVolumeLevelLoop:) userInfo:nil repeats:YES];

您可以更慢地运行循环,但用户会注意到音量又调高了)

&完成后不要忘记使循环无效:

[overideVolumeLoop invalidate];

这是基于此主题的:

在 iPhone 上设置设备音量< /a>

I just figured this one out.

I created a loop and used MPMusicPlayerController to return the volume to full every 10th of a second.

Loop function:

-(void) OverideVolumeLevelLoop:(NSTimer *)timer 
{ 
    [[MPMusicPlayerController applicationMusicPlayer] setVolume:1.0f]; 
}

Then just NSTimer to loop this function:

NSTimer *overideVolumeLoop = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(OverideVolumeLevelLoop:) userInfo:nil repeats:YES];

(You can run the loop slower but the user will notice the volume being raised back up)

& Dont forget to invalidate your loop when done:

[overideVolumeLoop invalidate];

This is based on this Thread:

Set device volume on iPhone

柠檬色的秋千 2024-12-11 13:53:42

您尝试过AVAudioPlayer的音量功能吗? IE

//some method that gets called when you want to play a sound
- (void)play sound {

audioPlayer.volume = 1.0;
[audioPlayer play];

}

Have you tried AVAudioPlayer's volume function? i.e

//some method that gets called when you want to play a sound
- (void)play sound {

audioPlayer.volume = 1.0;
[audioPlayer play];

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