Skip to content

Commit 50e7111

Browse files
committed
add background audio
1 parent bc34f85 commit 50e7111

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

cathedral_st_marys_sydney_cbd.mp3

2.43 MB
Binary file not shown.

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
</div>
164164
</div>
165165

166-
<audio loop autoplay>
167-
<source src="https://www.zapsplat.com/wp-content/uploads/2015/sound-effects-31172/zapsplat_public_places_cathedral_st_marys_sydney_cbd_internal_amb_traffic_outside_people_organist_tuning_sydney_australia002_32683.mp3" type="audio/mp3">
166+
<audio preload="auto" loop>
167+
<source src="cathedral_st_marys_sydney_cbd.mp3" type="audio/mp3">
168168
</audio>
169169

170170
<script type="module" src="./src/js/index.js"></script>

src/js/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { init, doorsOpen } from './auditorium.js';
22

33
const startApp = () => {
44
init().then(() => doorsOpen());
5+
6+
document.body.addEventListener('click', () => {
7+
const audio = document.querySelector('audio');
8+
if (!audio) return;
9+
10+
if (audio.currentTime <= 0 || audio.paused) {
11+
audio.play();
12+
return;
13+
}
14+
15+
audio.pause();
16+
});
517
};
618

719
document.addEventListener('DOMContentLoaded', startApp);

0 commit comments

Comments
 (0)