Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created January 13, 2019 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcinusX/7a679778fe30117be202923d0c64b528 to your computer and use it in GitHub Desktop.
Save MarcinusX/7a679778fe30117be202923d0c64b528 to your computer and use it in GitHub Desktop.
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