File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -44,11 +44,12 @@ function playClick() {
4444 console . log ( 'Play clicked' ) ;
4545 if ( ready ) {
4646 document . body . classList . add ( 'play' ) ;
47- startPlaying ( ) ;
47+ requestPlay ( ) ;
4848 ready = false ;
4949 }
5050}
5151
52+ // CRT scanning visual animation
5253function paintScreen ( ) {
5354 // Fill with gradient
5455 ctx . clearRect ( 0 , 0 , c . width , c . height ) ;
@@ -67,14 +68,20 @@ function paintScreen() {
6768 setTimeout ( paintScreen , scanY == c . height - 1 ? delay : interval ) ;
6869}
6970
70- // start when music is loaded
71- function startPlaying ( ) {
72- console . log ( 'Start playing..' ) ;
73- initCursor ( ) ;
74- document . getElementById ( "music" ) . play ( ) ;
75- initLyrics ( ) ;
76- initCredits ( ) ;
71+ // Request play
72+ function requestPlay ( ) {
73+ const audioElem = document . querySelector ( '#music' ) ;
74+ const startAnimation = function ( ) {
75+ initCursor ( ) ;
76+ initLyrics ( ) ;
77+ initCredits ( ) ;
78+ } ;
79+ audioElem . onplay = startAnimation ;
80+ // Request audio to start playing
81+ audioElem . play ( ) ;
7782}
83+
84+
7885/* LYRICS */
7986var lyricsIndex = 0 ;
8087function initLyrics ( ) {
You can’t perform that action at this time.
0 commit comments