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

以編程方式使 iOS 設(shè)備靜音/靜音?

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

問題描述

限時(shí)送ChatGPT賬號(hào)..

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

我知道它可以做到,可能使用像 AVSystemController 這樣的私有 API,并且我知道如果用戶期望應(yīng)用程序具有這種功能,Apple 仍然會(huì)批準(zhǔn)該應(yīng)用程序(因?yàn)槲乙呀?jīng)找到了 2 個(gè)應(yīng)用程序在 App Store 中,它以編程方式使設(shè)備靜音,無需越獄或類似的東西).

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

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

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

解決方案

這對(duì)我有用,我有一個(gè)按鈕可以在游戲中打開和關(guān)閉聲音.當(dāng)我想要聲音時(shí),我將浮動(dòng)設(shè)置為 10,當(dāng)我想要關(guān)閉聲音時(shí),我將浮動(dòng)設(shè)置為 0.

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

更新:

另一個(gè)仍然適用于 iOS 9.1 的選項(xiàng)

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

對(duì)于斯威夫特:

讓音量 = 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

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

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

相關(guān)文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應(yīng)用程序源代碼的情況下使用 Instruments 測(cè)試 iOS 應(yīng)用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動(dòng)運(yùn)行/壓力測(cè)試 iOS 應(yīng)用程序以找出罕見 UI 錯(cuò)誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標(biāo)成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態(tài)和動(dòng)態(tài)單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級(jí)到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 欧美一区二区三区在线观看视频 | 亚洲 欧美 另类 日韩 | 黑人粗黑大躁护士 | 亚洲一区二区在线电影 | 国精久久 | re久久| 国产一区在线看 | 在线国产一区 | 日韩国产一区二区三区 | 成人在线精品 | 成人精品一区二区 | 国产一区不卡在线观看 | 久久av网| 天天射天天操天天干 | 成年人网站国产 | 青青草一区 | 日韩在线一区二区三区 | 国产亚洲精品成人av久久ww | 黄色一级毛片 | 成人精品鲁一区一区二区 | 亚洲毛片| 欧美日韩成人一区二区 | 91久久精品一区二区二区 | 午夜无码国产理论在线 | 久久久久国产一区二区三区 | 日韩在线免费视频 | 国产视频精品区 | 欧美日韩精品久久久免费观看 | 久久精品国产一区 | 欧美综合精品 | 久久综合九色综合欧美狠狠 | 日韩精品专区在线影院重磅 | 国产精品视频入口 | 欧美区在线 | 欧美视频1区 | 羞羞视频在线观看 | 日韩在线免费视频 | 免费1区2区3区 | 在线看免费 | 台湾av在线 | 国产二区精品视频 |