Skip to content

Commit 52a24f5

Browse files
committed
Disable playback on simulator
1 parent 2fc8b45 commit 52a24f5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

firebaseai/LiveAudioExample/ViewModels/LiveViewModel.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class LiveViewModel: ObservableObject {
8787
return
8888
}
8989

90+
#if targetEnvironment(simulator)
91+
logger.warning("Playback audio is disabled on the simulator.")
92+
#endif
93+
9094
guard await requestRecordPermission() else {
9195
logger.warning("The user denied us permission to record the microphone.")
9296
return
@@ -213,7 +217,9 @@ class LiveViewModel: ObservableObject {
213217
for part in content.parts {
214218
if let part = part as? InlineDataPart {
215219
if part.mimeType.starts(with: "audio/pcm") {
220+
#if !targetEnvironment(simulator)
216221
try await audioController?.playAudio(audio: part.data)
222+
#endif
217223
} else {
218224
logger.warning("Received non audio inline data part: \(part.mimeType)")
219225
}

0 commit comments

Comments
 (0)