更新记录
1.0.5(2025-10-13)
- 优化iOS
1.0.4(2025-10-13)
- 升级Android sdk
1.0.3(2025-10-13)
- 优化Android
查看更多
平台兼容性
uni-app(4.81)
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
√ |
√ |
- |
- |
√ |
√ |
5.0 |
√ |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(4.81)
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
- |
- |
- |
- |
其他
VLC万能视频播放器,支持m3u8、mp4、rtmp、rtsp等等格式,本地远程视频
集成步骤
- 拷贝demo里的AndroidManifest.xml文件到项目根目录
- 集成插件,集成插件步骤请参考
https://www.cnblogs.com/wenrisheng/p/18323027
VLC内核版本:4.0.0
文档
组件
<wrs-uts-vlc ref='vlc' :params="params" :style="'width:'+width+'px;height:'+height+'px;'"
@onEvent="onEvent"></wrs-uts-vlc>
- 使用了该组件的页面需要用nvue或uvue
- 属性params是json格式的字符串
data() {
const {
windowWidth,
windowHeight
} = uni.getSystemInfoSync();
let url = "https://xxxxxx/xx.m3u8" // 或者/xxx/xxx/xxx.mp4
let params = {}
params.businessArray = [
{
business: "setUrl", // 设置播放地址
params: { // 业务参数
url: url,
autoPlay: true, // 是否自动播放
options: [ // vcl播放器参数,更多参数可以百度下
"--no-drop-late-frames", //防止掉帧
"--no-skip-frames", //防止掉帧
"--codec=ffmpeg", // 使用ffmpeg编码
"--rtsp-tcp", //强制使用TCP方式,强制rtsp-tcp,加快加载视频速度
"--avcodec-hw=any", //尝试使用硬件加速
"--live-caching=0" //缓冲时长
]
}
}]
let paramsStr = JSON.stringify(params)
let width = windowWidth
let height = width / (16.0 / 9.0)
return {
index: 0,
params: paramsStr,
width: width,
height: height,
urlArray: urlArray,
imageSrc: null,
msg: null,
title: 'Hello'
}
},
params.businessArray数组里支持的业务对象有:
let url = "https://xxxxxx/xx.m3u8"
// 支持远程或本地视频,本地视频地址如:/xxx/xxx/xxx.mp4
{
business: "setUrl", // 设置播放地址
params: { // 业务参数
url: url,
autoPlay: true, // 是否自动播放
options: [ // vcl播放器参数,更多参数可以百度下
"--no-drop-late-frames", //防止掉帧
"--no-skip-frames", //防止掉帧
"--codec=ffmpeg", // 使用ffmpeg编码
"--rtsp-tcp", //强制使用TCP方式,强制rtsp-tcp,加快加载视频速度
"--avcodec-hw=any", //尝试使用硬件加速
"--live-caching=0" //缓冲时长
]
}
}
{
business: "setVolume", // 业务
params: {
volume: 50 // 整形数字,一般是0~100
}
}
{
business: "setRate", // 业务
params: {
rate: 2 //倍速
}
}
快进到百分之多少
{
business: "setPosition", // 业务
params: {
position: 0.5 // 百分比进度:0~1
}
}
或者快进到第几秒
{
business: "setTime", // 业务
params: {
time: 10000 // 毫秒
}
}
{
business: "pause"
}
{
business: "play"
}
{
business: "setAspectRatio",
params: {
aspectRatio: "1000:600"
}
}
{
business: "setScale",
params: {
scale: 2.0
}
}
- android videoScale支持:DEFAULT, FILL_TO_SCREEN, 4:3, 16:9, 16:10, 2.21:1, FILL, 2.35:1, 2.39:1, 5:4, ORIGINAL
- ios videoScale支持:DEFAULT, FILL_TO_SCREEN, 4:3, 16:9, 16:10, 2.21:1,iOS其它比例需要各自去测试
{
business: "setVideoScale",
params: {
videoScale: "16:9"
}
}
// 本地图片保存路径
let path = "/xxx/xx/xx.jpg"
{
business: "snapshot", // 业务
params: {
path: path
}
}
onEvent(event) {
const detail = event.detail
console.log("onEvent detail:" + JSON.stringify(detail))
let opt = detail.opt
switch (opt) {
case "onLoadView": {
// 加载组件
}
break;
case "onLoadVLC": {
// 加载vlc播放器,调用了setUrl设置播放链接后onLoadVLC才会回调,在onLoadVLC才可以调用设置播放器的业务
}
break;
case "snapshot": {
// 截图回调
let suc = detail.flag
if (suc) {
let path = detail.filePath
this.imageSrc = "file://" + path
} else {
this.showMsg("截图失败:" + JSON.stringify(detail))
}
}
break;
case "onLengthChanged": {
// 获取到总时间
let length = detail.length
this.totalTime = this.formatTime(length)
}
break;
case "onTimeChange": {
// 播放进度时间更新
let time = detail.time
this.progressTime = this.formatTime(time)
}
break;
case "onPositionChanged": {
// 播放进度更新
let position = detail.position
this.position = position * 100
}
break;
default:
break;
}
},