久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

以編程方式使 iOS 設備靜音/靜音?

Mute/Silence an iOS device programmatically?(以編程方式使 iOS 設備靜音/靜音?)
本文介紹了以編程方式使 iOS 設備靜音/靜音?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試從我的應用程序中將設備的鈴聲靜音,但由于某種原因,使用 AVSystemController 就像在這個答案中一樣( 如何禁用 iOS 系統聲音 ) 不會讓我將設備完全靜音.. 它會將音量降至 1 bar,但并非完全靜音.p>

我知道它可以做到,可能使用像 AVSystemController 這樣的私有 API,并且我知道如果用戶期望應用程序具有這種功能,Apple 仍然會批準該應用程序(因為我已經找到了 2 個應用程序在 App Store 中,它以編程方式使設備靜音,無需越獄或類似的東西).

這些應用實際上做得更好——它們實際上切換了實際靜音,而不僅僅是將音量降低到零.

有人知道這是怎么做的嗎?

任何幫助將不勝感激!謝謝!

解決方案

這對我有用,我有一個按鈕可以在游戲中打開和關閉聲音.當我想要聲音時,我將浮動設置為 10,當我想要關閉聲音時,我將浮動設置為 0.

浮點值 = 0.0f;AudioSessionSetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, sizeof(float), &value);

更新:

另一個仍然適用于 iOS 9.1 的選項

float vol = [[AVAudioSession sharedInstance] outputVolume];NSLog(@"輸出音量:%1.2f dB", 20.f*log10f(vol+FLT_MIN));

對于斯威夫特:

讓音量 = AVAudioSession.sharedInstance().outputVolumeprint("輸出音量:(volume)")

更新答案的來源:Get System Volume iOS

I'm trying to mute the device's ringer from within my app, but for some reason using AVSystemController like in this answer ( How to disable iOS System Sounds ) won't let me silence the device ALL the way down.. it drops it to a volume of 1 bar, but not completely silent.

I know it can be done, probably with a private API like AVSystemController, and I know that Apple will still approve the app if the user expects this kind of functionality from the app (since there are already 2 apps I found in the App Store which mutes the device programmatically with no need of jailbreaking or anything like that).

Those apps actually do something better - they actually toggle the actual mute, not just decreasing the volume to zero.

Does anyone know the way this is being done?

Any help will be greatly appreciated! Thanks!

解決方案

This worked for me, I have a button that toggles sound on and off in a game. I set the float to 10 when I want sound on and 0 when I want sound off.

float value = 0.0f;
AudioSessionSetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, sizeof(float), &value);

Update:

Another option that is still working with iOS 9.1

float vol = [[AVAudioSession sharedInstance] outputVolume];
NSLog(@"output volume: %1.2f dB", 20.f*log10f(vol+FLT_MIN));

For Swift:

let volume = AVAudioSession.sharedInstance().outputVolume   
print("Output volume: (volume)")

Sources for updates answer: Get System Volume iOS

這篇關于以編程方式使 iOS 設備靜音/靜音?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應用程序源代碼的情況下使用 Instruments 測試 iOS 應用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 神马久久久久久久久久 | 日韩精品久久久久久 | 精品福利视频一区二区三区 | 91在线一区二区三区 | 亚洲国产成人精品女人久久久 | 国产精品99| 97久久久久久久久 | 一区二区三区国产精品 | 亚洲一区二区三区 | 久艹网站 | 青青草一区二区三区 | 免费一区 | 色综合久 | 99免费在线视频 | 久草中文在线 | 午夜av免费 | av网站在线播放 | 亚洲一区二区三 | 免费在线日韩 | 91看片在线 | 欧美爱爱视频网站 | 日韩欧美在线精品 | 99精品国产一区二区三区 | 亚洲综合首页 | 久久久久久久久久久久久91 | 影音先锋亚洲资源 | 久草免费在线视频 | 日韩在线精品视频 | 久久成人高清视频 | 亚洲人a| 91在线一区 | 国产精品久久久久久吹潮 | 99热这里有精品 | 国产一区二区在线免费观看 | 成人免费看片网 | 成人无遮挡毛片免费看 | 九九热精品免费 | 国产电影一区二区在线观看 | 成人性视频免费网站 | 美女高潮网站 | 视频一区二区在线观看 |