欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > vue3腾讯云直播 前端推流

vue3腾讯云直播 前端推流

2025/4/18 16:40:33 来源:https://blog.csdn.net/qq_40269801/article/details/147099289  浏览:    关键词:vue3腾讯云直播 前端推流

1、在index.html文件中引入(在body体中

<script src="https://video.sdk.qcloudecdn.com/web/TXLivePusher-2.1.1.min.js" charset="utf-8"></script>

2、vue文件中,添加video推流(我用的推流地址是webrtc)

<template><divid="local_video"ref="local_video"style="width: 100%; height: 500px; display: flex; align-items: center; justify-content: center"></div>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
const local_video = ref();
onMounted(async () => {const livePusher = new TXLivePusher();livePusher.setRenderView('local_video');livePusher.videoView.muted = true;// // 设置视频质量livePusher.setVideoQuality('720p');// // 设置音频质量livePusher.setAudioQuality('standard');// // 自定义设置帧率livePusher.setProperty('setVideoFPS', 25);// 采集完摄像头和麦克风之后自动推流Promise.all([livePusher.startCamera(), livePusher.startMicrophone()]).then(function () {livePusher.startPush('webrtc://232666.push.tlivecloud.com/live/live?txSecret=872632423847ksjdfkjdshh89327489327171&txTime=827436728');});
});
</script>

3、推流成功后,会在腾讯云控制台的流管理中看到

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词