Instantly share code, notes, and snippets.

@MarcinusX MarcinusX/main.dart Secret
Created Jan 13, 2019

Embed
What would you like to do?
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