command 就是事件名,可以写别的
<preview v-for="index in videoCount" v-on:command="onCommand" :key="'video'+(index-1)" :video-id="index-1" :order="playingDevice[index-1].order" :device-code="playingDevice[index-1].code" :player-div-height="videoHeight" :player-div-width="videoWidth"></preview>
methods: {
//接收并处理视频组件发来的命令
onCommand: async function (info) {
switch (info.order) {
case "closeVideo":
this.playingDevice[info.videoId].code = '';
break;
case "beginRecord":
if (!!!this.audioRecorder) {
await this.initAudio();
}
if (!this.streamServerAddress)
await this.getStreamServerIp();
this.audioRecorder.addWorker(info.videoId, "ws://" + this.streamServerAddress + "/cgmedia/websocket/pushaudiostream?id=" + this.playingDevice[info.videoId].code + "&transportport=" + info.port + "&format=mp3");
break;
case "stopRecord":
if (!!!this.audioRecorder) {
await this.initAudio();
}
this.audioRecorder.stopWorker(info.videoId);
break;
}
},
}
this.$emit('command', {order: "closeVideo", videoId: self.videoId})
评论区