JS视频加载SOMETIMES可以正常工作,其他时间未捕获(承诺)DOMException?

时间:2019-09-17 17:22:26

标签: javascript html css three.js

以三个JS纹理实现视频,我遇到了这样的问题:我的视频有时加载时没有错误,而其他时候却出现Uncaught (in promise) DOMException并且没有视频加载。

我认为问题是我需要等待视频加载后才能将其设置为素材:

var video = document.createElement( 'video' );
    video.src = './src/images/sintel.ogv';
    video.load(); // must call after setting/changing source
    video.preload = 'auto';
    video.autoload = true;
    video.play();


    var texture = new THREE.VideoTexture( video );
    texture.minFilter = THREE.LinearFilter;
    texture.magFilter = THREE.LinearFilter;
    texture.format = THREE.RGBFormat;

    // var runnerTexture = new THREE.ImageUtils.loadTexture( 'images/run.png' );
    // annie = new TextureAnimator( runnerTexture, 10, 1, 10, 75 ); // texture, #horiz, #vert, #total, duration.
    var runnerMaterial = new THREE.MeshBasicMaterial( { map: texture, side:THREE.DoubleSide } );

我不知道该怎么办。尝试将预加载添加到视频中,但无效。

0 个答案:

没有答案