This commit is contained in:
@@ -12,9 +12,9 @@ class VideoPlayer extends EventManager {
|
||||
return new Promise((resolve, reject)=>{
|
||||
vi = document.createElement('video');
|
||||
vi.src = engine.assetPath + data.$go.asset.name;
|
||||
vi.addEventListener('loadedmetadata', ()=>{
|
||||
vi.addEventListener('loadedmetadata', async ()=>{
|
||||
this.aspect = vi.videoWidth / vi.videoHeight;
|
||||
let geometry = new PlaneGeometry( this.aspect, 1 );
|
||||
let geometry = new PlaneGeometry( this.aspect * 0.88, 0.88 );
|
||||
let map = new VideoTexture( vi );
|
||||
map.colorSpace = SRGBColorSpace;
|
||||
let material = new MeshBasicMaterial( {
|
||||
@@ -34,26 +34,38 @@ class VideoPlayer extends EventManager {
|
||||
}
|
||||
});
|
||||
|
||||
vi.addEventListener('play', ()=>{
|
||||
material.opacity = 1
|
||||
const onPlay = ()=>{
|
||||
material.opacity = 1;
|
||||
if (data.playInHud && engine.dashboard?.active){
|
||||
engine.dashboard.attach(plane, {
|
||||
skipTransition: data.skipTransition
|
||||
});
|
||||
}
|
||||
})
|
||||
vi.addEventListener('pause', ()=>{
|
||||
//material.opacity = 0.5;
|
||||
}
|
||||
|
||||
const onPause = ()=>{
|
||||
if (data.playInHud){
|
||||
engine.dashboard?.detach(plane, {
|
||||
skipTransition: data.skipTransition
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
vi.addEventListener('play', onPlay);
|
||||
vi.addEventListener('pause', onPause);
|
||||
|
||||
vi.addEventListener('ended', ()=>{
|
||||
this.dispatchEvent({type:'finish'})
|
||||
})
|
||||
this.video = vi;
|
||||
|
||||
this.play = function(){
|
||||
try {
|
||||
vi.play();
|
||||
}catch(err){
|
||||
//TODO: show play button!!!
|
||||
}
|
||||
}
|
||||
|
||||
resolve(this);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user