Initial commit

This commit is contained in:
admin
2025-12-08 14:39:07 +08:00
commit 9d4f78656b
782 changed files with 66418 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# txv-video
功能:使用腾讯视频
大小:*≈1KB*
支持平台:
| 微信小程序 | QQ 小程序 | 百度小程序 | 支付宝小程序 | 头条小程序 | uni-app |
|:---:|:---:|:---:|:---:|:---:|:---:|
| √ | √ | | | | √ (h5 和 app 直接支持) |
说明:
引入本插件后,*html* 中符合下方格式的 *iframe* 标签(*src* 中含有 *vid*)将被转为通过腾讯视频播放:
```html
<iframe src="https://v.qq.com/txp/iframe/player.html?vid=xxxxxx" allowFullScreen="true"></iframe>
```
同时,其可以被 *pause-video* 属性控制
!> 本插件仅用于将官方 [腾讯视频插件](https://github.com/tvfe/txv-miniprogram-plugin) 应用于本组件,仅在微信和 *qq* 平台有效,使用前请确认已经成功申请使用该插件并按要求在小程序 *app.json* 中配置完成,否则可能报错 **This application has not registered any plugins yet** 且无法生效

View File

@@ -0,0 +1,3 @@
module.exports = {
platform: ['mp-weixin', 'mp-qq', 'uni-app']
}

View File

@@ -0,0 +1,46 @@
/**
* @fileoverview txv-video 插件
* Include txv-video (https://github.com/tvfe/txv-miniprogram-plugin)
*/
const TxvVideo = function (vm) {
this.vm = vm
}
// #ifdef MP-WEIXIN || MP-QQ
try {
const TxvContext = requirePlugin('tencentvideo')
TxvVideo.prototype.onLoad = function () {
setTimeout(() => {
for (let i = 0; i < this.videos.length; i++) {
const ctx = TxvContext.getTxvContext(this.videos[i])
ctx.id = this.videos[i]
this.vm._videos.push(ctx)
}
}, 50)
}
} catch (e) {
console.error('使用txv-video扩展需注册腾讯视频插件')
}
TxvVideo.prototype.onUpdate = function (_, config) {
config.trustTags['txv-video'] = true
this.videos = []
}
TxvVideo.prototype.onParse = function (node, parser) {
if (node.name === 'iframe' && (node.attrs.src || '').includes('vid')) {
const vid = node.attrs.src.match(/vid=([^&\s]+)/)
if (vid) {
node.name = 'txv-video'
node.attrs.vid = vid[1]
this.videos.push(vid[1])
node.attrs.src = undefined
parser.expose()
}
}
}
// #endif
module.exports = TxvVideo

View File

@@ -0,0 +1,6 @@
module.exports = {
template: '<txv-video wx:if="{{n.name==\'txv-video\'}}" vid="{{n.attrs.vid}}" playerid="{{n.attrs.vid}}" id="{{n.attrs.vid}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" controls data-i="{{i}}" bindplay="play" binderror="mediaError" />',
usingComponents: {
'txv-video': 'plugin://tencentvideo/video'
}
}

View File

@@ -0,0 +1,3 @@
module.exports = {
template: '<txv-video v-if="n.name==\'txv-video\'" :vid="n.attrs.vid" :playerid="n.attrs.vid" :id="n.attrs.vid" :class="n.attrs.class" :style="n.attrs.style" controls :data-i="i" @play="play" @error="mediaError" />'
}