-
-
Save MarcinusX/7a679778fe30117be202923d0c64b528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:audioplayers/audio_cache.dart'; | |
class _MainPageState extends State<MainPage> with SingleTickerProviderStateMixin { | |
AudioCache player = new AudioCache(); //<-- use AudioCache | |
... | |
void _onTap(Note note) { | |
... | |
_playNote(note); //<-- play a note on tap | |
setState(() { | |
note.state = NoteState.tapped; | |
++points; | |
}); | |
} | |
_playNote(Note note) { | |
switch (note.line) { //<-- choose a sound depending on the note's line | |
case 0: | |
player.play('a.wav'); | |
return; | |
case 1: | |
player.play('c.wav'); | |
return; | |
case 2: | |
player.play('e.wav'); | |
return; | |
case 3: | |
player.play('f.wav'); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment