Skip to content

Commit

Permalink
npx eslint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xdzqyyds committed Nov 19, 2024
1 parent 36bff61 commit c045e90
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
7 changes: 3 additions & 4 deletions webapp/components/device.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default function DeviceBar(props: { streamId: string }) {
setCurrentDeviceSpeaker,
setCurrentDeviceAudio,
setCurrentDeviceVideo,
toggleEnableSpeaker,
toggleEnableAudio,
toggleEnableVideo,
} = useWhipClient(props.streamId)
Expand Down Expand Up @@ -93,8 +92,8 @@ export default function DeviceBar(props: { streamId: string }) {
const videos = devices.filter(i => i.kind === 'videoinput').map(toDevice)

if ( currentDeviceSpeaker === deviceNone.deviceId) {
let device = speakers[0];
if (device) await setCurrentDeviceSpeaker(device.deviceId);
const device = speakers[0]
if (device) await setCurrentDeviceSpeaker(device.deviceId)
}

if (currentDeviceAudio === deviceNone.deviceId) {
Expand Down Expand Up @@ -170,7 +169,7 @@ export default function DeviceBar(props: { streamId: string }) {
return (
<div className="flex flex-row flex-wrap justify-around p-xs">
<center className="flex flex-row flex-wrap justify-around">
<section className="m-1 p-1 flex flex-row justify-center rounded-md border-1 border-indigo-500">
<section className="m-1 p-1 flex flex-row justify-center rounded-md border-1 border-indigo-500">
<button className="text-rose-400 rounded-md w-8 h-8" onClick={async () => {
}}>
<center>{ loadingSpeaker ? <Loading/> : <SvgSpeaker/> }</center>
Expand Down
2 changes: 1 addition & 1 deletion webapp/components/svg/speaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export default function SvgSpeaker() {
<svg focusable="false" width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" d="M4 7h4l5-5v20l-5-5H4c-1.1 0-2-.9-2-2V9c0-1.1.9-2 2-2zm11.54 3.88l1.41-1.41c1.78 1.78 1.78 4.66 0 6.44l-1.41-1.41c1.17-1.17 1.17-3.07 0-4.24zm2.83-2.83l1.41-1.41c3.12 3.12 3.12 8.19 0 11.31l-1.41-1.41c2.34-2.34 2.34-6.13 0-8.49z"></path>
</svg>
);
)
}

44 changes: 22 additions & 22 deletions webapp/components/use/whip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class WHIPContext extends Context {

constructor(id: string) {
super(id)
this.audioElement = document.createElement("audio")
this.audioElement = document.createElement('audio')
this.cache = this.clone()
}

Expand Down Expand Up @@ -109,36 +109,36 @@ class WHIPContext extends Context {
}

async setCurrentDeviceSpeaker(current: string) {
const { userStatus, currentDeviceSpeaker } = this;

// 检查是否需要切换设备
if (current !== currentDeviceSpeaker || !userStatus.speaker) {
if (!this.audioElement) {
// 使用全局或共享的 audioElement
this.audioElement = document.createElement("audio");
document.body.appendChild(this.audioElement);
}
const { userStatus, currentDeviceSpeaker } = this

// 检查是否需要切换设备
if (current !== currentDeviceSpeaker || !userStatus.speaker) {
if (!this.audioElement) {
// 使用全局或共享的 audioElement
this.audioElement = document.createElement('audio')
document.body.appendChild(this.audioElement)
}

// 设置新的扬声器设备
// 设置新的扬声器设备
if (this.audioElement.setSinkId) {
try {
await this.audioElement.setSinkId(current);
console.log(`扬声器切换到设备: ${current}`);
await this.audioElement.setSinkId(current)
console.log(`扬声器切换到设备: ${current}`)
} catch (error) {
console.error("切换音频输出设备失败:", error);
console.error('切换音频输出设备失败:', error)
}
} else {
console.error("当前浏览器不支持 setSinkId");
console.error('当前浏览器不支持 setSinkId')
}

// 更新状态
userStatus.speaker = current === deviceNone.deviceId ? false : true
this.currentDeviceSpeaker = current === deviceNone.deviceId ? this.currentDeviceSpeaker : current
// 更新状态
userStatus.speaker = current === deviceNone.deviceId ? false : true
this.currentDeviceSpeaker = current === deviceNone.deviceId ? this.currentDeviceSpeaker : current

// 同步状态并触发相关回调
this.sync();
this.syncUserStatus(userStatus);
}
// 同步状态并触发相关回调
this.sync()
this.syncUserStatus(userStatus)
}
}

onChangedDeviceAudio() {
Expand Down

0 comments on commit c045e90

Please sign in to comment.