Alot of changes
This commit is contained in:
@@ -67,19 +67,17 @@ class LiveInformation {
|
||||
syncedTimeModule = SyncedTimeModule();
|
||||
announcementModule = AnnouncementModule();
|
||||
|
||||
// Tracker module is not supported on desktop
|
||||
if (defaultTargetPlatform != TargetPlatform.windows && defaultTargetPlatform != TargetPlatform.linux && defaultTargetPlatform != TargetPlatform.macOS) {
|
||||
// Tracker module is not supported on web
|
||||
Permission.location.request().then((value) {
|
||||
if (value.isGranted) {
|
||||
trackerModule = TrackerModule();
|
||||
}
|
||||
});
|
||||
}
|
||||
initTrackerModule();
|
||||
|
||||
print("Initialised LiveInformation");
|
||||
}
|
||||
|
||||
Future<void> initTrackerModule() async {
|
||||
if (await Permission.location.isGranted) {
|
||||
trackerModule = TrackerModule();
|
||||
}
|
||||
}
|
||||
|
||||
// Auth
|
||||
AuthAPI auth = AuthAPI();
|
||||
|
||||
@@ -120,7 +118,15 @@ class LiveInformation {
|
||||
// Cache/Load the audio files
|
||||
await announcementModule
|
||||
.announcementCache
|
||||
.loadAnnouncementsFromBytes(await LiveInformation().announcementModule.getBundleBytes(), audioFiles);
|
||||
.loadAnnouncementsFromBytes(await LiveInformation().announcementModule.getBundleBytes(), [
|
||||
...audioFiles,
|
||||
if (!routeVariant.busRoute.routeNumber.toLowerCase().startsWith("ul"))
|
||||
"R_${routeVariant.busRoute.routeNumber}_001.mp3"
|
||||
else
|
||||
"R_RAIL_REPLACEMENT_SERVICE_001.mp3",
|
||||
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Public methods
|
||||
|
||||
@@ -88,10 +88,10 @@ class AnnouncementModule extends InfoModule {
|
||||
|
||||
if (currentAnnouncement!.audioSources.isNotEmpty) {
|
||||
|
||||
audioPlayer.loadSource(AudioWrapperAssetSource("assets/audio/5-seconds-of-silence.mp3"));
|
||||
audioPlayer.play();
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
audioPlayer.stop();
|
||||
// audioPlayer.loadSource(AudioWrapperAssetSource("assets/audio/5-seconds-of-silence.mp3"));
|
||||
// audioPlayer.play();
|
||||
// await Future.delayed(const Duration(milliseconds: 300));
|
||||
// audioPlayer.stop();
|
||||
|
||||
// try {
|
||||
for (AudioWrapperSource source in currentAnnouncement!.audioSources) {
|
||||
@@ -100,6 +100,8 @@ class AnnouncementModule extends InfoModule {
|
||||
|
||||
Duration? duration = await audioPlayer.play();
|
||||
await Future.delayed(duration!);
|
||||
audioPlayer.stop();
|
||||
// await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (currentAnnouncement?.audioSources.last != source) {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
@@ -256,25 +258,37 @@ class AnnouncementModule extends InfoModule {
|
||||
);
|
||||
return;
|
||||
}
|
||||
print("Checkpoint 4");
|
||||
|
||||
print(routeVariant);
|
||||
print("Checkpoint 4.1");
|
||||
|
||||
|
||||
String routeNumber = routeVariant.busRoute.routeNumber;
|
||||
String destination = routeVariant.destination!.destination;
|
||||
print("Checkpoint 4.2");
|
||||
|
||||
String destination = routeVariant.destination?.destination ?? "NullPointerException";
|
||||
print("Destination: $destination");
|
||||
print("Checkpoint 4.3");
|
||||
|
||||
|
||||
String audioRoute = "R_${routeVariant.busRoute.routeNumber}_001.mp3";
|
||||
|
||||
print("Checkpoint 5");
|
||||
await announcementCache.loadAnnouncementsFromBytes(await getBundleBytes(), [audioRoute, "R_RAIL_REPLACEMENT_SERVICE_001.mp3"]);
|
||||
|
||||
print("Checkpoint 6");
|
||||
AudioWrapperSource sourceRoute = !routeNumber.toLowerCase().startsWith("ul") ?
|
||||
AudioWrapperByteSource(announcementCache[audioRoute]!) :
|
||||
AudioWrapperByteSource(announcementCache["R_RAIL_REPLACEMENT_SERVICE_001.mp3"]!);
|
||||
print("Checkpoint 6.1");
|
||||
AudioWrapperSource sourceDestination = AudioWrapperByteSource(await routeVariant.destination!.getAudioBytes());
|
||||
|
||||
print("Checkpoint 7");
|
||||
AnnouncementQueueEntry announcement = AnnouncementQueueEntry(
|
||||
displayText: "$routeNumber to $destination",
|
||||
audioSources: [sourceRoute, AudioWrapperAssetSource("audio/to_destination.wav"), sourceDestination],
|
||||
scheduledTime: scheduledTime
|
||||
);
|
||||
|
||||
print("Checkpoint 8");
|
||||
queue.add(announcement);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,8 @@ class CommandModule extends InfoModule {
|
||||
else if (args[0].startsWith("dest")) {
|
||||
// announce destination <RouteNumber> <RouteVariantIndex> <ScheduledTime>
|
||||
|
||||
print("Checkpoint 1");
|
||||
|
||||
String routeNumber = args[1];
|
||||
int routeVariantIndex = int.parse(args[2]);
|
||||
|
||||
@@ -139,9 +141,11 @@ class CommandModule extends InfoModule {
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
print("Checkpoint 2");
|
||||
BusRoute route = LiveInformation().busSequences.routes[routeNumber]!;
|
||||
BusRouteVariant routeVariant = route.routeVariants.values.toList()[routeVariantIndex];
|
||||
|
||||
print("Checkpoint 3");
|
||||
liveInformation.announcementModule.queueAnnouncementByRouteVariant(
|
||||
routeVariant: routeVariant,
|
||||
scheduledTime: scheduledTime,
|
||||
|
||||
Reference in New Issue
Block a user