我在里面發現了幾個macOS系統的聲音
/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds
包括當你在finder中洗掉一個檔案時,在dock/drag to trash.aif中的垃圾箱聲音。
然而,我無法找到一個API來播放這些聲音。我真的希望不要對任何檔案路徑進行硬編碼。
PS:一個選擇可能是簡單地復制聲音到我自己的應用程式捆綁,但我也想盡可能地避免這樣做(也是許可?
uj5u.com熱心網友回復:
匯入AudioToolbox框架并使用AudioServicesPlaySystemSound函式。引數值沒有被記錄下來,并且和硬編碼的路徑一樣會被改變。它應該能通過應用程式商店的審查,因為它不是私有的API.
/drag to trash.aif
AudioServicesPlaySystemSound(0x10)。
/poof item of dock.aif
AudioServicesPlaySystemSound(0xf)。
唯一有記錄的值是:
CF_ENUM(SystemSoundID)
{
kSystemSoundID_UserPreferredAlert = 0x00001000,
kSystemSoundID_FlashScreen = 0x00000FFE,
//this has been renamed to be consistent.
kUserPreferredAlert = kSystemSoundID_UserPreferredAlert
};
這里是未記錄的值的串列
1 "Volume Mount.aif"
2 "Volume Unmount.aif"
3 "Media Keys.aif"/span>
4 "Sticky Keys ON.aif"/span>
5 "Sticky Keys OFF.aif"/span>
6 "Sticky Keys MODIFER.aif"
7 "Sticky Keys Locked.aif"
8 "Sticky Keys Stucked.aif"/span>
9 "Mouse Keys ON.aif"/span>
10 "Mouse Keys OFF.aif"/span>
11 "Slow Keys, 1st Key Pressed.aif"/span>
12 "Slow Keys, Key Registered.aif"/span>
13 " empty trash.aif"
14 "move to trash.aif"
15 "poof item off dock.aif"
16 "拖到垃圾箱.aif"
17 "InkSoundBecomeMouse.aif"
18 "InkSoundStroke1.aif"
19 "InkSoundStroke2.aif"
20 "InkSoundStroke3.aif"
21 "InkSoundStroke4.aif"
22 "burn complete.aif"/span>
23 "burn failed.aif"
24 "Grab.aif"/span>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/320047.html
標籤:
