【发布时间】:2019-02-11 16:54:13
【问题描述】:
Hiho 社区,
如果我的 videosphere 加载,我会尝试显示启动画面。我使用此代码 - > set a loading animation with a-frame 在场景之前加载启动画面并且效果很好,但我需要让我的视频具有预加载属性,所以如果我启动它们,它们也需要一些时间来加载并且应该弹出启动画面又起来了。一些想法(也许第二个听众说:如果视频加载则显示启动画面)?
HTML:
<body>
<div id="splash">
<div class="loading"></div>
</div>
<a-scene>
<a-assets>
<video id="vid" loop="false" preload="none"
crossorigin="anonymous">
<source type="video/mp4" src="..." />
</video>
</a-assets>
<a-videosphere src="#vid"></a-videosphere>
</a-scene>
</body>
CSS:
#splash {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 200px;
height: 200px;
margin: auto;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loading {
width: 24px;
height: 24px;
border-radius: 50%;
border: 0.25rem solid rgba(255, 255, 255, 0.2);
border-top-color: white;
animation: spin 1s infinite linear;
}
javascript:
document.addEventListener('DOMContentLoaded', function() {
var scene = document.querySelector('a-scene');
var splash = document.querySelector('#splash');
scene.addEventListener('loaded', function (e) {
splash.style.display = 'none';
});
});
【问题讨论】:
标签: javascript video load aframe virtual-reality