更新记录

1.0.5(2025-10-13)

  1. 优化iOS

1.0.4(2025-10-13)

  1. 升级Android sdk

1.0.3(2025-10-13)

  1. 优化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等等格式,本地远程视频

集成步骤

  1. 拷贝demo里的AndroidManifest.xml文件到项目根目录
  2. 集成插件,集成插件步骤请参考 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
    }
}
  • 设置视频界面宽高比
  1. 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
  2. ios videoScale支持:DEFAULT, FILL_TO_SCREEN, 4:3, 16:9, 16:10, 2.21:1,iOS其它比例需要各自去测试

{
    business: "setVideoScale",
    params: {
        videoScale: "16:9"
    }
}
  • 截屏,结果在onEvent回调

// 本地图片保存路径
let path = "/xxx/xx/xx.jpg"
{
    business: "snapshot", // 业务
    params: {
        path: path
    }
}
  • onEvent回调事件

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;
    }
},

隐私、权限声明

1. 本插件需要申请的系统权限列表:

网络权限

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率: