uniapp播放直播流(rtsp://xxxx),仅app或者app嵌套webview可用

2,420 阅读1分钟

video使用:uniapp.dcloud.net.cn/component/v…

components创建一个组件

<template>
	<view name="videoPlayer" class="flex flex-direction" style="width: 100%">
		<video width="100%" ref="media" controls="true" :src="videoUrl" :autoplay="true"
			:controls="false">
			您的浏览器不支持 video 标签。
		</video>
	</view>
</template>

<script setup>
	import {
		ref,
		computed,
		onMounted
	} from 'vue'
	const props = defineProps({
		videoSrc: {
			type: String,
			default: "",
		},
	})
	const videoUrl = ref(props.videoSrc)
</script>
<style></style>

使用

 <videoPlay videoSrc="rtsp://xxxxx"></videoPlay>

rtsp直接放进video是不行的,另外rtsp无法在h5播放