play intro song after scene load to prevent choppy

This commit is contained in:
Kevin Ngo
2018-09-25 03:57:02 -07:00
parent 447136b76c
commit b41c5e127c
2 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
AFRAME.registerComponent('intro-song', {
multiple: true,
play: function () {
const audio = document.getElementById('introSong');
audio.volume = 0.5;
audio.play();
}
});

View File

@@ -6,6 +6,9 @@
<script src="build/build.js"></script>
</head>
<body>
<audio id="introSong" src="assets/sounds/introSong.ogg" loop></audio>
<script>document.getElementById('introSong').volume = 0.5;</script>
<a-scene
bind__beat-loader="challengeId: challenge.id; difficulty: challenge.difficulty"
bind__song="challengeId: challenge.id; isPlaying: !menu.active && !challenge.isLoading"
@@ -14,6 +17,7 @@
console-shortcuts
debug-controller
effect-bloom="strength: 1"
intro-song
proxy-event="event: menuchallengeselect; to: #searchResultsContainer, #menuDifficultiesGroup"
overlay="objects: #menu, #keyboard, #rightHand, #leftHand"
search
@@ -47,8 +51,6 @@
<a-mixin id="textFont" text="font: assets/fonts/Teko-Bold.json; shader: msdf; letterSpacing: 1"></a-mixin>
</a-assets>
<audio id="introSong" src="assets/sounds/introSong.ogg" autoplay loop></audio>
<a-entity id="container">
{% include './templates/stage.html' %}
{% include './templates/gameUi.html' %}