ios 在 iPhone 模拟器中关闭声音
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3195739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Turn off sound in iPhone Simulator
提问by marko
Is there an option to turn off the sound on the iPhone Simulator? Or to adjust the volume?
是否可以选择关闭 iPhone 模拟器上的声音?或者调节音量?
采纳答案by Cameron Lowell Palmer
Partial Success - There are no good options
部分成功 - 没有好的选择
The iPhone Simulator selects the currently selected output at launch. Using Soundflower plugin and sending the audio to nowhere I started the iPhone Simulator. If you then switch to a different, working, output the simulator will remain 'muted' until you restart the simulator. So in general, you can attempt to trick the simulator to output to a dead end output.
iPhone 模拟器在启动时选择当前选定的输出。使用 Soundflower 插件并将音频发送到任何地方,我启动了 iPhone 模拟器。如果您随后切换到不同的工作输出,则模拟器将保持“静音”状态,直到您重新启动模拟器。所以一般来说,您可以尝试欺骗模拟器输出到死胡同。
Experimental setup - A sample video player
实验设置 - 示例视频播放器
I'm working on a solution to this problem and as a first step created a demonstration video player app. You can download VideoPlayerfrom GitHub for your own experiments.
我正在研究这个问题的解决方案,并作为第一步创建了一个演示视频播放器应用程序。您可以从 GitHub下载VideoPlayer用于您自己的实验。
First Attempt - Use a 3rd party app to mute it
第一次尝试 - 使用第 3 方应用将其静音
Tried using Audio HiHyman Proby Rogue Amoeba to hiHyman the audio stream and mute it. This didn't work and crashes the simulator. Contacted support and they reported that iPhone Simulator does some things that prevent them from hiHymaning the audio. I also looked into Soundflowerand Hyman.
尝试使用Rogue Amoeba 的Audio HiHyman Pro劫持音频流并将其静音。这不起作用并导致模拟器崩溃。联系了支持人员,他们报告说 iPhone Simulator 做了一些事情来防止他们劫持音频。我还研究了Soundflower和Hyman。
Second Attempt - In-app mute
第二次尝试 - 应用内静音
I was thinking maybe you could make a debug option where when in the app and on the simulator sound would be muted. However, within an app, only private APIs have the power to mute or reduce volume for the device. In the book iPhone Open Application DevelopmentChapter 6, Example "What's My Volume' gives sample code for manipulating system-wide sound through the AVSystemController. It might be fun to explore this route, but to make it into a weaponized tool would require a lot of trouble since you need to compile against private headers.
我在想也许你可以做一个调试选项,在应用程序和模拟器上的声音会被静音。但是,在应用程序中,只有私有 API 才能使设备静音或降低音量。在iPhone Open Application DevelopmentChapter 6, Example "What's My Volume' 中给出了通过 AVSystemController 操纵系统范围声音的示例代码。探索这条路线可能很有趣,但要把它变成一个武器化的工具需要很多麻烦,因为您需要针对私有标头进行编译。
Idea Three
理念三
Find a command-line option to pass to the Springboard or iPhone Simulator that will mute sound, or re-enable the volume control within the simulator, and of course be able to still launch the debugger.
找到一个命令行选项来传递给 Springboard 或 iPhone 模拟器,使声音静音,或者在模拟器中重新启用音量控制,当然仍然能够启动调试器。
Enhancement Request
高级请求
I filed an Apple Bug Reportenhancement request for both iPhone Simulator volume control, request 13428429, and per application volume control in Mac OS X, request 13428420. If you want these features, please file your own bug.
我为 iPhone 模拟器音量控制提交了Apple 错误报告增强请求,请求 13428429,以及 Mac OS X 中的每个应用程序音量控制,请求 13428420。如果您想要这些功能,请提交您自己的错误。
回答by Dominic Holmes
I ran into this -- my (working) music audio was being routed through the iOS simulator before reaching my headphones, making the music tinny and low-quality. This made developing in the sim really annoying. Fortunately there's an easy fix:
我遇到了这个问题——我的(工作)音乐音频在到达我的耳机之前通过 iOS 模拟器路由,这使得音乐声音很小而且质量很低。这使得在 sim 中开发真的很烦人。幸运的是,有一个简单的解决方法:
- In the simulator, route the incoming sound from your Mac's microphone
- Still in the simulator, route the outgoing audio through your Mac's speakers, or any other audio channel you aren't using
- 在模拟器中,路由来自 Mac 麦克风的传入声音
- 仍然在模拟器中,通过 Mac 的扬声器或您不使用的任何其他音频通道路由传出音频
Changing the incoming audio route:
更改传入音频路由:
Changing the outgoing audio route:
更改传出音频路由:
回答by brkeyal
Open iOS Simulator, press Hardware > Decrease Volume (?↓) until it's muted! I think it was added at Xcode 9.2, and that it's available only when running sim with iOS 11 and above
打开 iOS 模拟器,按硬件 > 降低音量 (?↓) 直到静音!我认为它是在 Xcode 9.2 中添加的,并且仅在使用 iOS 11 及更高版本运行 sim 时才可用
回答by Miscreant
1) Download the Loopbackapp
1) 下载环回应用
2) In Loopback, create a new virtual audio device (click New virtual device
). Rename it if you want (I named it Blackhole
).
2) 在 Loopback 中,创建一个新的虚拟音频设备(单击New virtual device
)。如果你想(我把它命名为重新命名它Blackhole
)。
3) In Simulator, click Hardware > Audio output
and choose the name of the virtual audio device that you just created.
3) 在模拟器中,单击Hardware > Audio output
并选择您刚刚创建的虚拟音频设备的名称。
回答by AzulValium
You can use something like...
你可以使用类似...
#if DEBUG
[ myAudioController setVolume: .1 ];
#endif
This way during testing, the app will have a lower volume.
这样在测试期间,应用程序的音量就会降低。
回答by Suhaiyl
referred from : iOS Simulator Sound
引用自:iOS 模拟器声音
Both the input and output device much match in system sound settings. Often u have them set to different devices. If they don't match, the simulator seems to default to the last connected audio device selected among the input and output devices.
输入和输出设备在系统声音设置上都非常匹配。通常你将它们设置为不同的设备。如果它们不匹配,模拟器似乎默认为在输入和输出设备中选择的最后连接的音频设备。
I hope it helps out in any way.
我希望它以任何方式有所帮助。
回答by ergunkocak
In my case i just set audio output to somewhere which is muted. Like my external screen :)
就我而言,我只是将音频输出设置为静音的某个地方。就像我的外屏 :)
回答by Nazariy Vlizlo
回答by Suragch
回答by Pushpak Narasimhan
[[MPMusicPlayerController applicationMusicPlayer] setVolume:0.0];
This works for device, just give a try for simulator. How do you set the hardware volume in an iPhone app?
这适用于设备,只需尝试模拟器。 如何在 iPhone 应用程序中设置硬件音量?
You can even try the reverse of this thread to see. Sound not working in iPhone Simulator?
您甚至可以尝试反向查看此线程。声音不是在iPhone模拟器工作?