summaryrefslogtreecommitdiff
path: root/lib/level.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/level.dart')
-rw-r--r--lib/level.dart65
1 files changed, 58 insertions, 7 deletions
diff --git a/lib/level.dart b/lib/level.dart
index c92658b..e35325a 100644
--- a/lib/level.dart
+++ b/lib/level.dart
@@ -1,12 +1,49 @@
+import 'dart:io';
+
import 'package:flutter/material.dart';
+import 'package:audioplayers/audioplayers.dart';
+
+class Level extends StatefulWidget {
+ const Level({super.key, required this.stepmaniaFolderPath});
+ final String stepmaniaFolderPath;
+
+ @override
+ State<Level> createState() => _LevelState();
+}
+
+class _LevelState extends State<Level> {
+ final _player = AudioPlayer();
+ bool _isPlaying = true;
-class Level extends StatelessWidget {
- const Level({super.key});
@override
Widget build(BuildContext context) {
+ String audioPath = Directory(widget.stepmaniaFolderPath)
+ .listSync()
+ .firstWhere((entity) => entity.path.endsWith('.ogg'),
+ orElse: () => File(''))
+ .path;
+ _player.play(DeviceFileSource(audioPath));
return Scaffold(
appBar: AppBar(
- leading: Icon(Icons.pause),
+ leading: IconButton(
+ icon: Icon(_isPlaying ? Icons.pause : Icons.play_arrow),
+ onPressed: () => {
+ if (_isPlaying)
+ {
+ _player.pause(),
+ setState(() {
+ _isPlaying = false;
+ })
+ }
+ else
+ {
+ _player.resume(),
+ setState(() {
+ _isPlaying = true;
+ })
+ },
+ },
+ ),
title: Text('Level 1'),
actions: [
IconButton(
@@ -15,10 +52,18 @@ class Level extends StatelessWidget {
],
),
body: Stack(children: [
- Arrow( position: -100.0,),
- Arrow( position: 00.0,),
- Arrow( position: 100.0,),
- Arrow( position: 200.0,),
+ Arrow(
+ position: -100.0,
+ ),
+ Arrow(
+ position: 00.0,
+ ),
+ Arrow(
+ position: 100.0,
+ ),
+ Arrow(
+ position: 200.0,
+ ),
Positioned(
top: 50,
width: MediaQuery.of(context).size.width,
@@ -43,6 +88,12 @@ class Level extends StatelessWidget {
),
]));
}
+
+ @override
+ void dispose() {
+ _player.dispose();
+ super.dispose();
+ }
}
class Arrow extends StatelessWidget {