import { defineComponent, reactive } from 'vue' import { ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElSlider, ElDialog, ElIcon } from 'element-plus' import runtime, * as RuntimeUtils from './runtime' import styles from './action-bar.module.less' import Share from './share' export const state = reactive({ volume: 30, barStatus: { camera: false, // 摄像头 volume: false, // 声音调节 microphone: false, // 麦克风 screen: false, // 共享屏幕 share: false, // 分享 }, shareVisiable: false }) export default defineComponent({ name: 'LiveBroadcast-ActionBar', computed: { isCameraDisabled() { return state.barStatus.camera && runtime.deviceStatus.camera !== 'denied' && runtime.cameras.length }, isMicrophoneDisabled() { const isDisabled = state.barStatus.microphone && runtime.deviceStatus.microphone !== 'denied' && runtime.microphones.length return isDisabled }, isVolumeDisabled() { return state.volume === 0 } }, methods: { startShare() { console.log('调用') state.shareVisiable = true }, volumeChange(value: number) { state.volume = value RuntimeUtils.setVolume(value) } }, render() { return (
{ state.barStatus.camera = !state.barStatus.camera RuntimeUtils.toggleDevice('camera') }} name={this.isCameraDisabled ? 'bar-camera-disabled' : 'bar-camera'} style={{ width: '22px', cursor: 'pointer' }} /> ( {runtime.cameras.map(item => ({item.label}))} ) }} >
摄像头
{ state.barStatus.volume = !state.barStatus.volume; if(!state.barStatus.volume) { sessionStorage.getItem('volume') && this.volumeChange(Number(sessionStorage.getItem('volume'))) } else { sessionStorage.setItem('volume', state.volume.toString()) this.volumeChange(0) } }} name={this.isVolumeDisabled ? 'bar-volume-disabled' : 'bar-volume'} style={{ width: '22px', cursor: 'pointer' }} /> (
) }} >
音量调节
屏幕共享
{/*
美颜
*/}
{ const needPublish = runtime.videoStatus === 'liveing' state.barStatus.microphone = !state.barStatus.microphone if (!state.barStatus.microphone) { RuntimeUtils.openDevice('microphone', needPublish) } else { RuntimeUtils.closeDevice('microphone', needPublish) } }} name={this.isMicrophoneDisabled ? 'bar-mike-disabled' : 'bar-mike'} style={{ width: '22px', cursor: 'pointer' }} /> ( {runtime.microphones.map(item => ({item.label}))} ) }} >
麦克风
分享
{/* 屏幕共享 */} { state.shareVisiable = false }}> state.shareVisiable = false}/>
) } })