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、推流成功后,會在騰訊云控制臺的流管理中看到