summaryrefslogtreecommitdiff
path: root/lib/level.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/level.dart')
-rw-r--r--lib/level.dart22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/level.dart b/lib/level.dart
index 1391f8a..369a162 100644
--- a/lib/level.dart
+++ b/lib/level.dart
@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
+import 'package:sense_the_rhythm/simfile.dart';
class Level extends StatefulWidget {
const Level({super.key, required this.stepmaniaFolderPath});
@@ -14,6 +15,7 @@ class Level extends StatefulWidget {
class _LevelState extends State<Level> {
final player = AudioPlayer();
+ Simfile? simfile;
bool _isPlaying = true;
Duration? _duration;
Duration? _position;
@@ -51,10 +53,7 @@ class _LevelState extends State<Level> {
_positionSubscription = player.onPositionChanged.listen(
(p) => setState(() => _position = p),
);
- }
- @override
- Widget build(BuildContext context) {
player.onDurationChanged.listen((Duration d) {
// print('Max duration: $d');
setState(() => _duration = d);
@@ -65,12 +64,29 @@ class _LevelState extends State<Level> {
setState(() => _position = p);
});
+ String simfilePath = Directory(widget.stepmaniaFolderPath)
+ .listSync()
+ .firstWhere((entity) => entity.path.endsWith('.sm'),
+ orElse: () => File(''))
+ .path;
+
String audioPath = Directory(widget.stepmaniaFolderPath)
.listSync()
.firstWhere((entity) => entity.path.endsWith('.ogg'),
orElse: () => File(''))
.path;
+
+ simfile = Simfile(simfilePath);
+ simfile!.load();
+
+ print(audioPath);
+
player.play(DeviceFileSource(audioPath));
+ }
+
+ @override
+ Widget build(BuildContext context) {
+
return Scaffold(
appBar: AppBar(
leading: IconButton(