侧边栏壁纸
  • 累计撰写 793 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索

目 录CONTENT

文章目录

组件事件

Dettan
2021-04-10 / 0 评论 / 0 点赞 / 190 阅读 / 181 字
温馨提示:
本文最后更新于 2022-07-23,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
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})

0

评论区