diff --git a/uni_modules/uni-video/changelog.md b/uni_modules/uni-video/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-video/package.json b/uni_modules/uni-video/package.json new file mode 100644 index 0000000000000000000000000000000000000000..8edcfae8c45d514cc35e7442b317515c3928f0cc --- /dev/null +++ b/uni_modules/uni-video/package.json @@ -0,0 +1,95 @@ +{ + "id": "uni-video", + "displayName": "uni-video", + "version": "1.0.0", + "description": "uni-video", + "keywords": [ + "uni-video" +], + "repository": "", + "engines": { + "HBuilderX": "^3.7.0" + }, + "dcloudext": { + "type": "component-uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [ + "uni-framework" + ], + "uni-ext-api": { + "uni": { + "createVideoContext": { + "name": "createVideoContext", + "app": { + "js": false, + "kotlin": true, + "swift": false + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-video/readme.md b/uni_modules/uni-video/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..2745019f691b0d7f80a9672b4bd072044550df56 --- /dev/null +++ b/uni_modules/uni-video/readme.md @@ -0,0 +1,6 @@ +# uni-video +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) \ No newline at end of file diff --git a/uni_modules/uni-video/utssdk/app-android/config.json b/uni_modules/uni-video/utssdk/app-android/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7a1a96612771ecceb441e3f416de951c6358d40e --- /dev/null +++ b/uni_modules/uni-video/utssdk/app-android/config.json @@ -0,0 +1,7 @@ +{ + "dependencies": [ + "com.github.bumptech.glide:glide:4.9.0", + "androidx.annotation:annotation:1.1.0", + "androidx.core:core:1.1.0" + ] +} \ No newline at end of file diff --git a/uni_modules/uni-video/utssdk/app-android/index.vue b/uni_modules/uni-video/utssdk/app-android/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..727fa64b276cf0252d1ac43d330b311b613419d4 --- /dev/null +++ b/uni_modules/uni-video/utssdk/app-android/index.vue @@ -0,0 +1,624 @@ + + + \ No newline at end of file diff --git a/uni_modules/uni-video/utssdk/app-android/libs/ijkplayer.aar b/uni_modules/uni-video/utssdk/app-android/libs/ijkplayer.aar new file mode 100644 index 0000000000000000000000000000000000000000..7df8babf2f52f1b57b23482bb7051d6181b1db92 Binary files /dev/null and b/uni_modules/uni-video/utssdk/app-android/libs/ijkplayer.aar differ diff --git a/uni_modules/uni-video/utssdk/app-android/libs/videoplayer.aar b/uni_modules/uni-video/utssdk/app-android/libs/videoplayer.aar new file mode 100644 index 0000000000000000000000000000000000000000..bc2d098fa5da42b1767703d75ca5cfb83ff5dce2 Binary files /dev/null and b/uni_modules/uni-video/utssdk/app-android/libs/videoplayer.aar differ diff --git a/uni_modules/uni-video/utssdk/app-ios/index.vue b/uni_modules/uni-video/utssdk/app-ios/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..1b0b528488e0c97b8861e399b39cd26f38f43863 --- /dev/null +++ b/uni_modules/uni-video/utssdk/app-ios/index.vue @@ -0,0 +1,20 @@ + + diff --git a/uni_modules/uni-video/utssdk/index.uts b/uni_modules/uni-video/utssdk/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..0f13918e104360c7f28379b1d904e65721924cff --- /dev/null +++ b/uni_modules/uni-video/utssdk/index.uts @@ -0,0 +1,58 @@ +import { ComponentPublicInstance } from 'vue' +import { CreateVideoContext, VideoContext, RequestFullScreenOptions, Danmu } from './interface' +import { UniVideoElement } from './app-android/index.vue' + +export const createVideoContext : CreateVideoContext = function (videoId : VideoIdString, component : ComponentPublicInstance | null) : VideoContext | null { + let videoElement : Element | null = null; + if (component == null) { + const pages = getCurrentPages(); + if (pages.length > 0) { + videoElement = pages[pages.length - 1].$querySelector('#' + videoId); + } + } else { + videoElement = component.$querySelector('#' + videoId); + } + if (videoElement == null) return null; + return new VideoContextImpl(videoElement as UniVideoElement); +} + +class VideoContextImpl implements VideoContext { + + private videoElement : UniVideoElement; + + constructor(videoElement : UniVideoElement) { + this.videoElement = videoElement; + } + + play() { + this.videoElement.play(); + } + + pause() { + this.videoElement.pause(); + } + + seek(position : number) { + this.videoElement.seek(position); + } + + stop() { + this.videoElement.stop(); + } + + sendDanmu(danmu : Danmu) { + this.videoElement.sendDanmu(danmu); + } + + playbackRate(rate : number) { + this.videoElement.playbackRate(rate); + } + + requestFullScreen(direction : RequestFullScreenOptions | null) { + this.videoElement.requestFullScreen(direction); + } + + exitFullScreen() { + this.videoElement.exitFullScreen(); + } +} \ No newline at end of file diff --git a/uni_modules/uni-video/utssdk/interface.uts b/uni_modules/uni-video/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..dbba10de8a37d17498110f3b68ce8c9d9d72b05a --- /dev/null +++ b/uni_modules/uni-video/utssdk/interface.uts @@ -0,0 +1,171 @@ +import { ComponentPublicInstance } from 'vue' + +export type CreateVideoContext = (videoId: VideoIdString, component?: ComponentPublicInstance | null) => VideoContext | null; + +export type Danmu = { + /** + * 弹幕文字 + */ + text: string | null, + /** + * 弹幕颜色 + */ + color: string | null, + /** + * 显示时刻 + */ + time: number | null +}; + +export type RequestFullScreenOptions = { + /** + * direction + * - 0: 正常竖向 + * - 90: 屏幕逆时针90度 + * - -90: 屏幕顺时针90度 + * @type 0 | 90 | -90 + */ + direction: number | null +}; + +export interface VideoContext { + /** + * @description 播放 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + play(): void; + /** + * @description 暂停 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + pause(): void; + /** + * @description 跳转到指定位置 + * @param {number} position 跳转到指定位置(秒) + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + seek(position: number): void; + /** + * @description 停止视频 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + stop(): void; + /** + * @description 发送弹幕 + * @param {Danmu} 属性 text, color + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + sendDanmu(danmu: Danmu): void; + /** + * @description 设置倍速播放 + * @param {number} rate, 支持倍率 0.5/0.8/1.0/1.25/1.5 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + playbackRate(rate: number): void; + /** + * @description 进入全屏 + * @param {RequestFullScreenOptions} direction, 0|正常竖向, 90|屏幕逆时针90度, -90|屏幕顺时针90度 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + requestFullScreen(direction: RequestFullScreenOptions | null): void; + /** + * 退出全屏 + * @description 退出全屏 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 + */ + exitFullScreen(): void; +} + +export interface Uni { + /** + * 创建并返回 video 上下文 videoContext 对象 + * @description 创建并返回 video 上下文 videoContext 对象 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4", + * "uniVer": "√", + * "unixVer": "√" + * } + * } + * } + * @uniVueVersion 2,3 + * @return {VideoContext} 视频对象 + * + * @tutorial http://uniapp.dcloud.io/api/media/video-context?id=createVideoContext + * + */ + createVideoContext(videoId : string | HBuilderX.VideoIdString, component?: ComponentPublicInstance | null) : VideoContext | null +} \ No newline at end of file