聲音¶
ArctosLinks.Media 提供了一套 API 來播放與關閉聲音訊號的輸出。
啟用聲音輸出¶
功能:啟用聲音訊號輸出。
返回值:
import ArctosLinks
private func enableSpeaker() {
ArctosLinks.Media.enableSpeaker { result in
switch result {
case .success():
print("Successfully set audio output to the speaker.")
case .failure(let error):
displayNotification(title: "💀 Failed to set audio output to the speaker", body: error.localizedDescription)
}
}
}
停用聲音輸出¶
功能:停用聲音訊號輸出。
返回值:
import ArctosLinks
private func disableSpeaker() {
ArctosLinks.Media.disableSpeaker { result in
switch result {
case .success():
print("Successfully stop audio output.")
case .failure(let error):
displayNotification(title: "💀 Failed to stop speaker audio output.", body: error.localizedDescription)
}
}
}