聲音
ArctosLinks.Media
提供了一套 API 來播放與關閉聲音訊號的輸出。
啟用聲音輸出
功能:啟用聲音訊號輸出。
返回值:
Swift
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)
}
}
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks
private fun enableSpeaker() {
runCatching {
ArctosLinks.getInstance(Context).mediaManager.enableSpeaker().getOrThrow()
}.onFailure {
Log.d(TAG, "enableSpeaker: Failed ${it.message}")
}
}
c++
#include "arctos_qt.h"
void enableSpeaker() {
auto& arctos_app = arctos::ArctosQt::getInstance();
arctos_app.media()->enableSpeaker();
}
停用聲音輸出
功能:停用聲音訊號輸出。
返回值:
Swift
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)
}
}
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks
private fun disableSpeaker() {
runCatching {
ArctosLinks.getInstance(Context).mediaManager.disableSpeaker().getOrThrow()
}.onFailure {
Log.d(TAG, "disableSpeaker: ${it.message}")
}
}
c++
#include "arctos_qt.h"
void disableSpeaker() {
auto& arctos_app = arctos::ArctosQt::getInstance();
arctos_app.media()->disableSpeaker();
}