alpha-video-player-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/dist/alpha-video-player-js.d.ts +48 -0
- package/dist/alpha-video-player-js.js +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# alpha-video-player-js
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
|
|
5
|
+
alpha-video-player-js 是一个 Web 视频动画特效播放 sdk,可以通过制作 Alpha 通道分离的视频素材,在 Web 端通过 WebGL 或 Canvas 重新实现 RGB 通道和 Alpha 通道的融合,从而实现播放带透明通道的视频。
|
|
6
|
+
|
|
7
|
+
- 零依赖
|
|
8
|
+
|
|
9
|
+
- 接入体积小(3.95K)
|
|
10
|
+
- 还原度高
|
|
11
|
+
- 兼容 WebGL(GPU) 及 Canvas(CPU) 降级,性能优异
|
|
12
|
+
- 支持 横向 - RGB 通道视频在前、横向 - RGB 通道视频在后、纵向 - RGB 通道视频在前、纵向 - RGB 通道视频在后 四类视频融合
|
|
13
|
+
|
|
14
|
+
## 使用
|
|
15
|
+
|
|
16
|
+
### 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm i alpha-video-player-js
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 创建实例
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
import AlphaVideoPlayerJs from 'alpha-video-player-js'
|
|
26
|
+
|
|
27
|
+
const player = new AlphaVideoPlayerJs(config)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 实例参数
|
|
31
|
+
|
|
32
|
+
| 参数 | 含义 | 默认值 | 是否必传 |
|
|
33
|
+
| ------------- | ---------------------------------- | --------- | -------- |
|
|
34
|
+
| container | dom 容器 | null | 是 |
|
|
35
|
+
| src | 播放地址 | '' | 是 |
|
|
36
|
+
| width | 渲染宽度(默认取父级宽度) | - | 否 |
|
|
37
|
+
| height | 渲染高度(默认取父级高度) | - | 否 |
|
|
38
|
+
| muted | 是否静音播放 | true | 否 |
|
|
39
|
+
| loop | 是否循环播放 | false | 否 |
|
|
40
|
+
| playbackRate | 播放速率 | 1 | 否 |
|
|
41
|
+
| fps | 播放帧率 | 0 | 否 |
|
|
42
|
+
| videoFrame | 是否启用 requestVideoFrameCallback 渲染 | false | 否 |
|
|
43
|
+
| orientation | 视频排布方式 landscape \| portrait | landscape | 否 |
|
|
44
|
+
| side | RGB 通道视频位置 front \| back | front | 否 |
|
|
45
|
+
| autoShow | 是否自动显示(初始化后自动显示第一帧) | false | 否 |
|
|
46
|
+
| autoClear | 是否自动清除(播放完毕后自动清除显示内容) | true | 否 |
|
|
47
|
+
| autoDestroy | 是否自动销毁(播放完毕后自动销毁 canvas 与 video 元素) | false | 否 |
|
|
48
|
+
| debug | 是否开启 sdk 错误打印 | false | 否 |
|
|
49
|
+
| onInitSuccess | 初始化成功回调 | - | 否 |
|
|
50
|
+
| onInitError | 初始化失败回调 | - | 否 |
|
|
51
|
+
| onLoad | 加载完毕回调 | - | 否 |
|
|
52
|
+
| onCanPlay | 可以播放回调 | - | 否 |
|
|
53
|
+
| onPlay | 开始播放回调 | - | 否 |
|
|
54
|
+
| onLood | 循环播放回调 | - | 否 |
|
|
55
|
+
| onPause | 暂停播放回调 | - | 否 |
|
|
56
|
+
| onEnded | 结束播放回调 | - | 否 |
|
|
57
|
+
| onError | 播放错误回调 | - | 否 |
|
|
58
|
+
| onDestroy | 销毁实例回调 | - | 否 |
|
|
59
|
+
|
|
60
|
+
### 实例属性
|
|
61
|
+
|
|
62
|
+
| 方法 | 含义 | 类型 |
|
|
63
|
+
| ------- | ---------- | ------- |
|
|
64
|
+
| playing | 是否播放中 | Boolean |
|
|
65
|
+
| loop | 是否循环 | Boolean |
|
|
66
|
+
|
|
67
|
+
### 实例方法
|
|
68
|
+
|
|
69
|
+
| 方法 | 含义 | 参数 |
|
|
70
|
+
| ----------------------------- | ---------------- | ------------------- |
|
|
71
|
+
| play() | 播放/继续播放 | - |
|
|
72
|
+
| pause() | 暂停播放 | - |
|
|
73
|
+
| destroy() | 销毁实例 | - |
|
|
74
|
+
| reset() | 重置播放进度 | - |
|
|
75
|
+
| setSrc(src) | 设置播放地址 | 播放地址(string) |
|
|
76
|
+
| setCurrentTime(time) | 设置播放进度 | 播放进度(number,秒) |
|
|
77
|
+
| setMute(muted) | 设置是否静音播放 | 是否静音(boolean) |
|
|
78
|
+
| setLoop(loop) | 设置是否循环播放 | 是否循环(boolean) |
|
|
79
|
+
| setPlaybackRate(playbackRate) | 设置播放倍速 | 播放倍速(number) |
|
|
80
|
+
|
|
81
|
+
## 原理
|
|
82
|
+
|
|
83
|
+
- WebGLRender 使用 webgl texture 获取 video RGB 通道视频 和 Alpha 通道视频纹理,并在 shader 中进行自定义融合
|
|
84
|
+
- CanvasRender 使用 canvas2d getImageData 获取 video RGB 通道视频 和 Alpha 通道视频图片元数据,并进行自定义融合
|
|
85
|
+
|
|
86
|
+
## 示例
|
|
87
|
+
|
|
88
|
+
https://test-web.bxyuer.com/alpha-video-player-js-demo
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
interface IConfig {
|
|
2
|
+
container: HTMLElement;
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
src: string;
|
|
6
|
+
muted?: boolean;
|
|
7
|
+
loop?: boolean;
|
|
8
|
+
playbackRate?: number;
|
|
9
|
+
fps?: number;
|
|
10
|
+
orientation?: IOrientation;
|
|
11
|
+
side?: ISide;
|
|
12
|
+
videoFrame?: boolean;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
autoShow?: boolean;
|
|
15
|
+
autoClear?: boolean;
|
|
16
|
+
autoDestroy?: boolean;
|
|
17
|
+
onInitSuccess?: () => void;
|
|
18
|
+
onInitError?: (e: ErrorEvent) => void;
|
|
19
|
+
onLoad?: () => void;
|
|
20
|
+
onCanPlay?: () => void;
|
|
21
|
+
onPlay?: () => void;
|
|
22
|
+
onLoop?: () => void;
|
|
23
|
+
onPause?: () => void;
|
|
24
|
+
onEnded?: () => void;
|
|
25
|
+
onError?: (e: ErrorEvent) => void;
|
|
26
|
+
onDestroy?: () => void;
|
|
27
|
+
}
|
|
28
|
+
type IOptionalConfig = Omit<IConfig, 'container' | 'src'> & Partial<Pick<IConfig, 'container' | 'src'>>;
|
|
29
|
+
type IOrientation = 'landscape' | 'portrait';
|
|
30
|
+
type ISide = 'front' | 'back';
|
|
31
|
+
|
|
32
|
+
declare class Render {
|
|
33
|
+
private render;
|
|
34
|
+
constructor(config: IConfig);
|
|
35
|
+
get playing(): boolean;
|
|
36
|
+
get loop(): boolean;
|
|
37
|
+
play(config?: IOptionalConfig): void;
|
|
38
|
+
pause(): void;
|
|
39
|
+
destroy(): void;
|
|
40
|
+
reset(): void;
|
|
41
|
+
setSrc(src: string): void;
|
|
42
|
+
setCurrentTime(time: number): void;
|
|
43
|
+
setMute(muted: boolean): void;
|
|
44
|
+
setLoop(loop: boolean): void;
|
|
45
|
+
setPlaybackRate(playbackRate: number): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { type IConfig, Render as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};function e(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function i(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}"function"==typeof SuppressedError&&SuppressedError;var o=window.devicePixelRatio,i={landscape:{front:[0,1,.5,1,0,0,.5,0],back:[.5,1,1,1,.5,0,1,0]},portrait:{front:[0,1,1,1,0,.5,1,.5],back:[0,.5,1,.5,0,0,1,0]}},n=function(t,e,o){return"landscape"===t?"width"===e?2*o:o:"width"===e?o:2*o},r=function(t){if(!t)throw new Error("[alpha-video-player-js]: setting failed, please instantiate first!")},a=window,s=a.requestAnimationFrame||a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame,d=a.cancelAnimationFrame||a.mozCancelAnimationFrame||a.webkitCancelAnimationFrame||a.msCancelAnimationFrame,h=function(){function t(t){if(this.canvasWidth=0,this.canvasHeight=0,this.videoWidth=0,this.videoHeight=0,this.animationId=0,this.onCanPlayTimes=1,this.canPlay=!1,this.adaptAnimation=null,this.playing=!1,!t.container||!t.src)throw new Error("[alpha-video-player-js]: container or src can not be empty!");this.setConfig(t),this.container=t.container,this.canvas=function(t,e,i){var n=t.offsetWidth,r=t.offsetHeight,a=document.createElement("canvas");return a.width=(e||n)*o,a.height=(i||r)*o,a.style.width="100%",a.style.height="100%",a.style.pointerEvents="none",t.appendChild(a),a}(this.container,t.width,t.height);var e=this.canvas,i=e.width,n=e.height;this.canvasWidth=i,this.canvasHeight=n,this.initVideo()}return Object.defineProperty(t.prototype,"loop",{get:function(){var t;return(null===(t=this.video)||void 0===t?void 0:t.loop)||!1},enumerable:!1,configurable:!0}),t.prototype.setConfig=function(t){t&&(this.config=Object.assign({playbackRate:1,muted:!0,loop:!1,fps:0,orientation:"landscape",side:"front",autoShow:!1,autoClear:!0,autoDestroy:!1,debug:!1,videoFrame:!1},this.config||{},t))},t.prototype.initVideo=function(){var t=this.config,e=t.src,o=t.playbackRate,i=t.muted,n=t.loop,r=this.video=document.createElement("video");r.src=e,r.crossOrigin="anonymous",r.autoplay=!1,r.preload="auto",r.playbackRate=o,r.loop=n,r.muted=i,r.setAttribute("playsinline",""),r.setAttribute("webkit-playsinline",""),r.setAttribute("x-webkit-airplay",""),r.style.display="none",document.body.appendChild(r),r.load(),this.bindInstance(),this.addEvent()},t.prototype.drawFrameOnce=function(){},t.prototype.drawFrame=function(){var t=this.drawFrame.bind(this);this.adaptAnimation||(this.adaptAnimation=this.initAdaptAnimation()),this.animationId=this.adaptAnimation(t),this.playing=!0},t.prototype.initAdaptAnimation=function(){var t=this,e=this.config,o=e.videoFrame,i=e.fps;if("requestVideoFrameCallback"in HTMLVideoElement.prototype&&o)return function(e){return t.video.requestVideoFrameCallback(e)};if(s){if(i){var n=-1;return function(e){return n++,s((function(){if(n%(60/i)==0)return e();t.animationId=t.adaptAnimation(e)}))}}return function(t){return s(t)}}return function(t){return window.setTimeout(t,1e3/i)}},t.prototype.cancelDrawFrame=function(){var t=this.animationId,e=this.config;t&&(this.video.cancelVideoFrameCallback&&e.videoFrame?this.video.cancelVideoFrameCallback(t):d?d(t):window.clearTimeout(t),this.animationId=0,this.playing=!1)},t.prototype.play=function(t){r(this.video),t&&this.setConfig(t),this.video.play(),this.drawFrame()},t.prototype.pause=function(){r(this.video),this.video.pause(),this.cancelDrawFrame()},t.prototype.reset=function(){this.setCurrentTime(0)},t.prototype.setSrc=function(t){r(this.video),this.video.src=t,this.video.load(),this.video.currentTime=0},t.prototype.setCurrentTime=function(t){r(this.video),this.video.currentTime=t},t.prototype.setMute=function(t){r(this.video),this.video.muted=t},t.prototype.setLoop=function(t){r(this.video),this.video.loop=t},t.prototype.setPlaybackRate=function(t){r(this.video),this.video.playbackRate=t},t.prototype.onLoad=function(){var t=this.video,e=this.config,o=t.videoWidth,i=t.videoHeight;this.videoWidth=o,this.videoHeight=i,e.onLoad&&e.onLoad()},t.prototype.onCanplay=function(){var t=this.config;this.canPlay=!0,t.autoShow&&this.drawFrameOnce(),1===this.onCanPlayTimes&&t.onCanPlay&&t.onCanPlay(),1!==this.onCanPlayTimes&&t.loop&&t.onLoop&&t.onLoop(),this.onCanPlayTimes++},t.prototype.onPlay=function(){var t=this.config;t.onPlay&&t.onPlay()},t.prototype.onPause=function(){var t=this.config;t.onPause&&t.onPause()},t.prototype.onEnded=function(){var t=this.config;this.video.currentTime=0,this.cancelDrawFrame(),t.onEnded&&t.onEnded()},t.prototype.onError=function(t){var e=this.config;e.onError&&e.onError(t),this.destroy()},t.prototype.destroy=function(){try{var t=this.config;this.cancelDrawFrame(),this.removeEvent(),this.video.pause(),this.video.src="",this.video.load(),this.video.parentNode.removeChild(this.video),t.onDestroy&&t.onDestroy(),this.config=null,this.container=null,this.video=null,this.animationId=null}catch(t){}},t.prototype.bindInstance=function(){var t=this,e=t.onLoad,o=t.onCanplay,i=t.onPlay,n=t.onPause,r=t.onEnded,a=t.onError;this.onLoad=e.bind(this),this.onCanplay=o.bind(this),this.onPlay=i.bind(this),this.onPause=n.bind(this),this.onEnded=r.bind(this),this.onError=a.bind(this)},t.prototype.addEvent=function(){var t=this,e=t.video,o=t.onLoad,i=t.onCanplay,n=t.onPlay,r=t.onPause,a=t.onEnded,s=t.onError;e.addEventListener("loadedmetadata",o),e.addEventListener("canplaythrough",i),e.addEventListener("play",n),e.addEventListener("pause",r),e.addEventListener("ended",a),e.addEventListener("error",s)},t.prototype.removeEvent=function(){var t=this,e=t.video,o=t.onLoad,i=t.onCanplay,n=t.onPlay,r=t.onPause,a=t.onEnded,s=t.onError;e.removeEventListener("loadedmetadata",o),e.removeEventListener("play",n),e.removeEventListener("canplaythrough",i),e.removeEventListener("pause",r),e.removeEventListener("ended",a),e.removeEventListener("error",s)},t}(),c=function(t){function o(e){var o=this,i=e.onInitSuccess,n=e.onInitError;try{(o=t.call(this,e)||this).initWebGLRender(),i&&i()}catch(t){n&&n(t)}return o}return e(o,t),o.prototype.initWebGLRender=function(){var t=this.canvas,e=this.gl=t.getContext("webgl")||t.getContext("experimental-webgl");e.disable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.viewport(0,0,t.width,t.height),this.vertexShader=this.initShader(e.VERTEX_SHADER,"#define GLSLIFY 1\nattribute vec4 a_Position;attribute vec2 a_Video_Texture_Position;attribute vec2 a_Alpha_Video_Texture_Position;varying vec2 v_Video_Texture_Position;varying vec2 v_Alpha_Video_Texture_Position;void main(){gl_Position=a_Position;v_Video_Texture_Position=a_Video_Texture_Position;v_Alpha_Video_Texture_Position=a_Alpha_Video_Texture_Position;}"),this.fragmentShader=this.initShader(e.FRAGMENT_SHADER,"precision lowp float;\n#define GLSLIFY 1\nuniform sampler2D u_Sampler;varying vec2 v_Video_Texture_Position;varying vec2 v_Alpha_Video_Texture_Position;void main(){gl_FragColor=vec4(texture2D(u_Sampler,v_Video_Texture_Position).rgb,texture2D(u_Sampler,v_Alpha_Video_Texture_Position).r);}"),this.program=this.initProgram(),this.texture=this.initTexture(),this.vertexBuffer=this.initVertexBuffer()},o.prototype.initShader=function(t,e){var o=this.gl,i=o.createShader(t);if(o.shaderSource(i,e),o.compileShader(i),this.config.debug){var n=o.getShaderParameter(i,o.COMPILE_STATUS);console.log("[alpha-video-player-js] shader compile result: ",t,n),n||console.log("[alpha-video-player-js] shader compile fail: ",t,o.getShaderInfoLog(i))}return i},o.prototype.initProgram=function(){var t=this.gl,e=t.createProgram();if(t.attachShader(e,this.vertexShader),t.attachShader(e,this.fragmentShader),t.linkProgram(e),this.config.debug){var o=t.getProgramParameter(e,t.LINK_STATUS);console.log("[alpha-video-player-js] program connect shader result: ",o),o||console.log("[alpha-video-player-js] program connect shader fail: ",t.getProgramInfoLog(e))}return t.useProgram(e),e},o.prototype.initTexture=function(){var t=this.gl,e=t.createTexture();return t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,1),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e},o.prototype.initVertexBuffer=function(){var t=this,e=t.gl,o=t.program,n=t.config,r=function(t,e){var o="front"===e,n=[-1,1,1,1,-1,-1,1,-1],r=i[t][o?"front":"back"],a=i[t][o?"back":"front"],s=[];return n.forEach((function(t,e){e%2==0&&(s=s.concat(n.slice(e,e+2)).concat(r.slice(e,e+2)).concat(a.slice(e,e+2)))})),new Float32Array(s)}(n.orientation,n.side),a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW);var s=r.BYTES_PER_ELEMENT,d=e.getAttribLocation(o,"a_Position");e.vertexAttribPointer(d,2,e.FLOAT,!1,6*s,0),e.enableVertexAttribArray(d);var h=e.getAttribLocation(o,"a_Video_Texture_Position");e.vertexAttribPointer(h,2,e.FLOAT,!1,6*s,2*s),e.enableVertexAttribArray(h);var c=e.getAttribLocation(o,"a_Alpha_Video_Texture_Position");e.vertexAttribPointer(c,2,e.FLOAT,!1,6*s,4*s),e.enableVertexAttribArray(c);var l=e.getUniformLocation(o,"u_Sampler");return e.uniform1i(l,0),a},o.prototype.drawFrameOnce=function(){var t=this.gl,e=this.video;t&&e&&this.canPlay&&(t.clear(t.COLOR_BUFFER_BIT),t.texImage2D(t.TEXTURE_2D,0,t.RGB,t.RGB,t.UNSIGNED_BYTE,e),t.drawArrays(t.TRIANGLE_STRIP,0,4))},o.prototype.drawFrame=function(){this.drawFrameOnce(),t.prototype.drawFrame.call(this)},o.prototype.onEnded=function(){var e=this.gl,o=this.config;o.autoClear&&e.clear(e.COLOR_BUFFER_BIT),t.prototype.onEnded.call(this),o.autoDestroy&&this.destroy()},o.prototype.destroy=function(){var e,o=this,i=o.canvas,n=o.gl,r=o.vertexShader,a=o.fragmentShader,s=o.texture,d=o.vertexBuffer,h=o.program;i&&n&&(t.prototype.destroy.call(this),i.parentNode.removeChild(i),n.detachShader(h,r),n.deleteShader(r),n.detachShader(h,a),n.deleteShader(a),n.deleteTexture(s),n.deleteBuffer(d),n.deleteProgram(h),null===(e=n.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext(),this.canvas=null,this.gl=null,this.vertexShader=null,this.fragmentShader=null,this.texture=null,this.vertexBuffer=null,this.program=null)},o}(h),l=function(t){function o(e){var o=this,i=e.onInitSuccess,n=e.onInitError;try{(o=t.call(this,e)||this).initCanvasRender(),i&&i()}catch(t){n&&n(t)}return o}return e(o,t),o.prototype.initCanvasRender=function(){var t=this,e=t.canvas,o=t.canvasWidth,i=t.canvasHeight,r=t.config,a=r.orientation,s=r.side,d=document.createElement("canvas");this.tempCanvasWidth=d.width=n(a,"width",o),this.tempCanvasHeight=d.height=n(a,"height",i);var h=function(t,e,o,i){var n=[0,0,o,i],r=[o,0,o,i],a=[0,0,o,i],s=[0,i,o,i],d=n,h=r;return"landscape"===t?(d="front"===e?n:r,h="front"===e?r:n):(d="front"===e?a:s,h="front"===e?s:a),{imageCoords:d,alhpaImageCoords:h}}(a,s,o,i),c=h.imageCoords,l=h.alhpaImageCoords;this.imageCoords=c,this.alhpaImageCoords=l,this.context2d=e.getContext("2d"),this.tempContext2d=d.getContext("2d")},o.prototype.drawFrameOnce=function(){var t=this,e=t.context2d,o=t.tempContext2d,i=t.video,n=t.canPlay,r=t.videoWidth,a=t.videoHeight,s=t.tempCanvasWidth,d=t.tempCanvasHeight,h=t.imageCoords,c=t.alhpaImageCoords;if(e&&o&&i&&n&&r&&a&&s&&d&&h&&c){o.drawImage(i,0,0,r,a,0,0,s,d);for(var l=o.getImageData.apply(o,h),p=l.data,u=o.getImageData.apply(o,c).data,v=3;v<p.length;v+=4)p[v]=u[v-1];e.putImageData(l,0,0)}},o.prototype.drawFrame=function(){this.drawFrameOnce(),t.prototype.drawFrame.call(this)},o.prototype.onEnded=function(){var e=this,o=e.context2d,i=e.canvasWidth,n=e.canvasHeight,r=e.config;r.autoClear&&o.clearRect(0,0,i,n),t.prototype.onEnded.call(this),r.autoDestroy&&this.destroy()},o.prototype.destroy=function(){var e=this.canvas;e&&(t.prototype.destroy.call(this),e.parentNode.removeChild(e),this.canvas=null,this.context2d=null,this.tempContext2d=null,this.tempCanvasWidth=null,this.tempCanvasHeight=null,this.imageCoords=null,this.alhpaImageCoords=null)},o}(h),p=function(){function t(t){if((e=document.createElement("canvas")).getContext("webgl")||e.getContext("experimental-webgl"))this.render=new c(t);else{if(!document.createElement("canvas").getContext("2d"))throw new Error("[alpha-video-player-js]: Your browser does not support play. Please upgrade your browser and try again.");this.render=new l(t)}var e}return Object.defineProperty(t.prototype,"playing",{get:function(){return this.render.playing},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loop",{get:function(){return this.render.loop},enumerable:!1,configurable:!0}),t.prototype.play=function(t){this.render.play(t)},t.prototype.pause=function(){this.render.pause()},t.prototype.destroy=function(){this.render.destroy()},t.prototype.reset=function(){this.render.reset()},t.prototype.setSrc=function(t){this.render.setSrc(t)},t.prototype.setCurrentTime=function(t){this.render.setCurrentTime(t)},t.prototype.setMute=function(t){this.render.setMute(t)},t.prototype.setLoop=function(t){this.render.setLoop(t)},t.prototype.setPlaybackRate=function(t){this.render.setPlaybackRate(t)},t}();export{p as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alpha-video-player-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Web 视频动画特效播放 sdk",
|
|
5
|
+
"main": "dist/alpha-video-player-js.js",
|
|
6
|
+
"types": "dist/alpha-video-player-js.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "rollup -c -w",
|
|
10
|
+
"build": "cross-env NODE_ENV=production rollup -c",
|
|
11
|
+
"release": "bash ./scripts/release.sh",
|
|
12
|
+
"postpublish": "git push && git push --tags"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"alpha",
|
|
16
|
+
"video",
|
|
17
|
+
"player",
|
|
18
|
+
"webgl",
|
|
19
|
+
"canvas"
|
|
20
|
+
],
|
|
21
|
+
"author": "https://github.com/trp1119",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://git.yupaopao.com/terminal/fe/infrastructure/alpha-video-player-js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"package.json"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
36
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
37
|
+
"cross-env": "^7.0.3",
|
|
38
|
+
"rollup": "^3.29.2",
|
|
39
|
+
"rollup-plugin-dts": "^6.0.2",
|
|
40
|
+
"rollup-plugin-filesize": "^10.0.0",
|
|
41
|
+
"rollup-plugin-glslify": "^1.3.1",
|
|
42
|
+
"rollup-plugin-typescript2": "^0.35.0",
|
|
43
|
+
"tslib": "^2.6.2",
|
|
44
|
+
"typescript": "^5.2.2"
|
|
45
|
+
}
|
|
46
|
+
}
|