Initial Commit
This commit is contained in:
64
lib/pages/audio_cache_test.dart
Normal file
64
lib/pages/audio_cache_test.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
import 'package:bus_infotainment/audio_cache.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AudioCacheTest extends StatelessWidget {
|
||||
|
||||
AnnouncementCache _announcementCache = AnnouncementCache();
|
||||
|
||||
AudioCacheTest({super.key}) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
"AudioCacheTest"
|
||||
)
|
||||
),
|
||||
|
||||
body: Container(
|
||||
child: FutureBuilder(
|
||||
future: _announcementCache.loadAllAnnouncements(),
|
||||
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
|
||||
List<Widget> announcements = [];
|
||||
|
||||
for (var key in _announcementCache.keys) {
|
||||
|
||||
announcements.add(
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
AudioPlayer player = AudioPlayer();
|
||||
player.play(BytesSource(_announcementCache[key]));
|
||||
},
|
||||
child: Text(
|
||||
key
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return ListView(
|
||||
children: announcements,
|
||||
);
|
||||
} else {
|
||||
return CircularProgressIndicator();
|
||||
}
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user