Skip to content

Commit

Permalink
Comply with autoplay policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubidumdu committed Mar 21, 2024
1 parent 973dadf commit 09823ed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pages/visualizer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
Funky Town - Lipps Inc.
</option>
</select>
<div class="start">
<button>Start</button>
</div>
<script type="module" src="./main.ts"></script>
</body>
</html>
10 changes: 9 additions & 1 deletion pages/visualizer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const init = async () => {
};

const audio = document.getElementById('audio') as HTMLAudioElement;
audio.style.display = 'block';
const select = document.getElementById('musicSelect') as HTMLSelectElement;
select.style.display = 'block';

audio.src = audioTracks['backInBlack'];

Expand Down Expand Up @@ -238,4 +240,10 @@ const init = async () => {
});
};

init();
const startButton = document.querySelector('.start > button');

startButton?.addEventListener('click', () => {
init();
startButton.parentElement?.remove();
audio.star;

Check failure on line 248 in pages/visualizer/main.ts

View workflow job for this annotation

GitHub Actions / Build

Cannot find name 'audio'. Did you mean 'Audio'?
});
19 changes: 19 additions & 0 deletions pages/visualizer/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
canvas {
background: black;
position: absolute;
top: 0;
left: 0;
Expand All @@ -21,14 +22,32 @@ input {

audio {
position: absolute;
display: none;
width: 300px;
left: 16px;
top: 16px;
}

select {
position: absolute;
display: none;
left: 16px;
top: 80px;
width: 300px;
}

.start {
width: 100%;
height: 100%;
position: fixed;
background: black;
display: flex;
justify-content: center;
align-items: center;

& > button {
width: 200px;
height: 100px;
font-size: 2rem;
}
}

0 comments on commit 09823ed

Please sign in to comment.