<template>
<view name="videoPlayer" class="flex flex-direction" style="width: 100%;">
<video id="myVideo" class="response" :src="videoUrl" :title="videoTitle"
controls="true"
page-gesture="true"
object-fit="contain"
show-mute-btn="true"
enable-play-gesture="true"
is-live="true"
vslide-gesture="true"
@error="videoErrorCallback"
@waiting="videoWaiting"
@loadedmetadata="videoLoadOk"
style="width: 100%;"></video>
</view>
</template>
<script>
export default {
name: 'videoPlayer',
props: {
title: { type: String, default: '' },
firstPic: { type: String, default: '' },
videoType: { type: String, default: '' },
videoSrc: { type: String, default: '' }
},
data() {
return {
videoUrl: this.videoSrc,
firstImg: this.firstPic,
videoTitle: this.title
};
},
watch: {
videoSrc() {
this.setVideoUrl();
}
},
mounted() {
this.setVideoUrl();
},
onReady() {
this.videoContext = uni.createVideoContext('myVideo');
},
methods: {
setVideoUrl() {
this.videoUrl = this.videoSrc;
this.firstImg = this.firstPic;
this.videoTitle = this.title;
},
videoErrorCallback(e) {
console.log("+++++++")
console.log(e)
// uni.showModal({ content: e.target.errMsg, showCancel: false });
},
videoWaiting() {
// uni.showLoading({ title: '加载中' });
},
videoLoadOk() {
// uni.hideLoading();
}
}
};
</script>
<style>
/ 样式代码 /
</style>

- 发布:2025-10-10 14:05
- 更新:2025-10-10 14:50
- 阅读:23
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 11
手机系统: Android
手机系统版本号: Android 16
手机厂商: 华为
手机机型: 18081598046
页面类型: vue
vue版本: vue2
打包方式: 离线
项目创建方式: CLI
CLI版本号: 4.5.19
示例代码:
操作步骤:
<template>
<view>
<!-- 仅在APP-PLUS平台使用 -->
<video-player title="视频标题" videoSrc="rtsp://192.168.222.171:8554/rtsp001"></video-player>
</view>
</template>
<script>
import VideoPlayer from '@/common/video-player';
export default {
components: {
VideoPlayer
}
};
</script>
<template>
<view>
<!-- 仅在APP-PLUS平台使用 -->
<video-player title="视频标题" videoSrc="rtsp://192.168.222.171:8554/rtsp001"></video-player>
</view>
</template>
<script>
import VideoPlayer from '@/common/video-player';
export default {
components: {
VideoPlayer
}
};
</script>
预期结果:
可直接播放
可直接播放
实际结果:
无法播放无法加载
无法播放无法加载
bug描述:
期望为可正常播放
实际效果为无法加载rtsp视频流
2 个回复
用户2904244
顶顶顶顶
用户2904244
顶顶顶