-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
33 lines (29 loc) · 1017 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Player from './src/index';
import wasmBinary from './src/wasm-binary';
import videoData from './video-data';
window.addEventListener('load',async () => {
const wrapHeight = window.innerHeight;
const wrapWidth = Math.floor(window.innerHeight / videoData.height * videoData.width);
const wrap = {
height: wrapHeight,
width: wrapWidth,
top: 0,
left: -(wrapWidth - window.innerWidth) / 2 | 0,
};
const wrapDom = document.querySelector('.canvas-wrap');
wrapDom.style.width = wrap.width + 'px';
wrapDom.style.height = wrap.height + 'px';
wrapDom.style.top = wrap.top + 'px';
wrapDom.style.left = wrap.left + 'px';
const canvas = document.querySelector('#video-content');
canvas.width = wrapWidth;
canvas.height = wrapHeight;
const player = new Player(videoData.url, {
canvas,
wasmBinary,
loop: true,
autoplay: true,
disableWebAssembly: true,
});
window.player = player;
}, false);