更新记录
1.0.5(2024-09-10)
修复uniapp安卓端崩溃
1.0.4(2024-09-04)
新增options配置参数
1.0.3(2024-09-02)
修复bug
查看更多
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.7.0,Android:5.0,iOS:11,HarmonyNext:不确定 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
yzc-vlckit 兼容安卓、iOS端VLC播放器,支持rtsp、rtmp流播放
uniappx用法
参数
参数 |
类型 |
是否必须 |
描述 |
url |
string |
是 |
播放连接 |
options |
string数组 |
否 |
配置vlc,只在初始化配置有效 |
options配置可参考
方法
|方法名|参数|说明|
|play|无参|播放方法|
|pause|无参|暂停方法|
|stop|无参|停止方法|
组件引入
<vlc-video
ref="video"
class="video"
:options="vlcOptions"
url="rtsp://xxxxx"
@mediaPlayerStateChanged="mediaPlayerStateChanged"
@mediaPlayerTimeChanged="mediaPlayerTimeChanged"
></vlc-video>
类型导入
import { StateInfoType, TimeInfoType } from '@/uni_modules/yzc-vlckit/utssdk/interface.uts';
选项时API
export default {
data() {
return {
videoElement: null as VlcVideoElement | null
}
},
onLoad() {
},
methods: {
btnClick() {
if (this.videoElement == null) {
this.videoElement = this.$refs['video'] as VlcVideoElement
}
this.videoElement?.play()
// this.videoElement?.pause()
// this.videoElement?.stop()
},
// 状态改变回调方法
mediaPlayerStateChanged(res: StateInfoType) {
console.log('video: state', res.state)
},
// 时间改变回调方法
mediaPlayerTimeChanged(res: TimeInfoType) {
console.log('video: time', res.time)
}
}
}
组合式API
const video = ref(null)
const btnClick = (() => {
(video.value as VlcVideoElement).play()
// (video.value as VlcVideoElement).pause()
// (video.value as VlcVideoElement).stop()
})
// 状态改变回调方法
const mediaPlayerStateChanged = ((res: StateInfoType) => {
console.log('video: state', res.state)
})
// 时间改变回调方法
const mediaPlayerTimeChanged = ((res: TimeInfoType) => {
console.log('video: time', res.time)
})
uniapp用法
export default {
data() {
return {
}
},
onLoad() {
},
methods: {
btnClick() {
this.$refs['video'].play()
// this.$refs['video'].pause()
// this.$refs['video'].stop()
},
// 状态改变回调方法
mediaPlayerStateChanged(res) {
console.log('video: state', res.detail.state)
},
// 时间改变回调方法
mediaPlayerTimeChanged(res) {
console.log('video: time', res.detail.time)
}
}
}
mediaPlayerStateChanged方法回调说明
state说明
类型 |
描述 |
'buffering' |
缓冲 |
'playing' |
正在播放 |
'stopped' |
播放暂停 |
'stopped' |
播放停止 |
'ended' |
播放结束 |
'error' |
播放错误 |
mediaPlayerTimeChanged方法回调说明
time说明 返回为ms的整数类型