Skip to content

Commit

Permalink
maybe fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoyama committed Jan 26, 2025
1 parent 35802ef commit 17afeb3
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/composables/qall/useLiveKitSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const tracksMap: Ref<Map<string, TrackInfo>> = ref(new Map())
const cameraProcessorMap: Ref<Map<string, CameraProcessor>> = ref(new Map())
const screenShareTrackSidMap = ref<Map<string, string>>(new Map())
const mixer = ref<AudioStreamMixer>()
const audioTrackId = ref<string>()

Check warning on line 95 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L87-L95

Added lines #L87 - L95 were not covered by tests

function handleTrackSubscribed(
track: RemoteTrack,
Expand Down Expand Up @@ -310,13 +311,16 @@ const addMicTrack = async () => {
throw new Error('Failed to get audio track')
}

Check warning on line 312 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L309-L312

Added lines #L309 - L312 were not covered by tests

audioTrackId.value = audioTrack.id

Check warning on line 314 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L314

Added line #L314 was not covered by tests

// Publish the processed stream
await room.value.localParticipant.publishTrack(audioTrack, {
audioPreset: AudioPresets.musicHighQualityStereo,
forceStereo: true,
red: false,
dtx: false
})
isMicOn.value = true

Check warning on line 323 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L317-L323

Added lines #L317 - L323 were not covered by tests

} catch (e) {
console.error(e)

Check warning on line 326 in src/composables/qall/useLiveKitSDK.ts

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement

Check warning on line 326 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L325-L326

Added lines #L325 - L326 were not covered by tests
Expand All @@ -336,7 +340,17 @@ const removeMicTrack = async () => {
addErrorToast('ルームが存在しません')
return
}
await room.value.localParticipant.setMicrophoneEnabled(false)
for (const [trackSid, trackInfo] of tracksMap.value) {
if (trackInfo.isRemote) continue
if (trackInfo.trackPublication?.track?.id === audioTrackId.value) {
if (audioContext.value) {
await audioContext.value.close()
audioContext.value = undefined
}
await trackInfo.trackPublication?.track?.mute()
}
}

Check warning on line 352 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L337-L352

Added lines #L337 - L352 were not covered by tests
// await room.value.localParticipant.setMicrophoneEnabled(false)
} catch (e) {
console.error(e)

Check warning on line 355 in src/composables/qall/useLiveKitSDK.ts

View workflow job for this annotation

GitHub Actions / run lint

Unexpected console statement
addErrorToast('マイクのミュートに失敗しました')
Expand All @@ -348,10 +362,23 @@ const toggleMicTrack = async () => {
addErrorToast('ルームが存在しません')
return
}
if (room.value.localParticipant?.isMicrophoneEnabled) {
if (isMicOn.value) {
await removeMicTrack()
} else {
await addMicTrack()
if (!room.value) {
addErrorToast('ルームが存在しません')
return
}
for (const [trackSid, trackInfo] of tracksMap.value) {
if (trackInfo.isRemote) continue
if (trackInfo.trackPublication?.track?.id === audioTrackId.value) {
if (audioContext.value) {
await audioContext.value.close()
audioContext.value = undefined
}
await trackInfo.trackPublication?.track?.unmute()
}
}
}
}

Check warning on line 383 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L360-L383

Added lines #L360 - L383 were not covered by tests

Expand Down

0 comments on commit 17afeb3

Please sign in to comment.