我正在尝试在我的场景中动态添加一些视频。但问题是我只有我视频的第一帧。 但有时会播放视频,并且每个帧之间都会冻结。
我将视频放入资产中,然后在js脚本中加载了我的视频。
<a-assets>
<a-asset-item id="model_obj" src="model/my_model.obj"
></a-asset-item>
<a-asset-item id = "man" src = "model/avatar.obj"></a-asset-item>
<video id= "my_video_1" autoplay=true loop="true" src ="video_1.mp4" ></video>
<img id="sky" src="model/ls.jpg">
</a-assets>
然后在我的js脚本中(我在html的末尾调用它):
setTimeout(function(){
var scene = document.getElementById("my_s");
var tv_ent_1 = document.createElement("a-entity");
var tv_ent_2 = document.createElement("a-entity");
var vid_1 = document.createElement("a-video");
var vid_2 = document.createElement("a-video");
var mov_1 = document.getElementById("my_video_1");
tv_ent_1.setAttribute('geometry', "primitive:plane");
tv_ent_1.setAttribute('position', "8.929 1.775 -8.245" );
tv_ent_1.setAttribute('rotation', "1 -90 0");
tv_ent_1.setAttribute('material', "src : #my_video_1");
tv_ent_1.setAttribute('scale',"1.48 0.8 1" );
scene.appendChild(tv_ent_1);
tv_ent_2.setAttribute('geometry', "primitive:plane");
tv_ent_2.setAttribute('position', "7.207 1.511 -3.268" );
tv_ent_2.setAttribute('rotation', "-180 0 0");
tv_ent_2.setAttribute('material', "src : #my_video_1");
tv_ent_2.setAttribute('scale',"2.39 -1.76 1" );
scene.appendChild(tv_ent_2);
vid_1.setAttribute('src', "#my_video_1");
vid_1.setAttribute('height', 1);
vid_1.setAttribute('width', 1);
/*vid_1.setAttribute('video-illumination', "intensity :0.1");
vid_1.setAttribute('video-illumination', "distance :2");*/
vid_2.setAttribute('src', "#my_video_1");
vid_2.setAttribute('height', 1);
vid_2.setAttribute('width', 1);
/* vid_2.setAttribute('video-illumination', "intensity :0.1");
vid_2.setAttribute('video-illumination', "distance :2");*/
tv_ent_1.appendChild(vid_1);
tv_ent_2.appendChild(vid_2);
mov_1.play();
mov_1.muted = true;
}, 4000);
我不知道视频资产的运作方式。有没有办法强制加载视频?
谢谢大家:)