您好,黑色是因为视频没有自动播放,您在js中添加这段代码:
function toggleSound() { var music = document.getElementById("trailer");//获取ID if (music.paused) {//判读是否播放 music.paused=false; music.play();//没有就播放 } } setInterval("toggleSound()",1);
您好,我加入以上代码会报错找不到toggleSound,直接运行toggleSound();函数就可以播放了,但也有几次会出现播放黑色的现象。
现在我将video设置为静音muted模式,它也可以播放运行,代码如下,
<video id="trailer" style="display:none" muted autoplay loop crossorigin controls>
<div id="toolbar">
<source src="media/video.mp4" type="video/mp4">
</video>
</div>
js代码:
var projectionImage = new Cesium.ProjectionImage(scene);
var wgsPosition = scene.camera.positionCartographic;
var longitude = Cesium.Math.toDegrees(wgsPosition.longitude);
var latitude = Cesium.Math.toDegrees(wgsPosition.latitude);
var height = wgsPosition.height;
projectionImage.setDistDirByPoint([longitude, latitude, height]);
projectionImage.distance = 200; //观测距离
projectionImage.viewPosition = [longitude, latitude, height]; //设置起始位置
projectionImage.direction = 180;
projectionImage.pitch = -18;
projectionImage.horizontalFov = 30;
projectionImage.verticalFov = 10;
projectionImage.hintLineColor = Cesium.Color.DODGERBLUE;
projectionImage.setImage({
video: videoElement
});
projectionImage.build();
请问是我写的有问题吗?