v2.37 — Issue #6: Auto-Scan beim Start + Timer.periodic alle 3h
- MusikScanner().scanneMusikOrdner() wird direkt nach Auth-Init aufgerufen - Timer.periodic alle 3 Stunden für periodischen Scan - androidStopForegroundOnPause=false für persistente Notification (Issue #8) Build: ✓ flutter analyze
This commit is contained in:
+24
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
import 'package:audio_service/audio_service.dart';
|
import 'package:audio_service/audio_service.dart';
|
||||||
@@ -29,7 +30,7 @@ void main() async {
|
|||||||
config: const AudioServiceConfig(
|
config: const AudioServiceConfig(
|
||||||
androidNotificationChannelId: 'de.baka.melo.audio',
|
androidNotificationChannelId: 'de.baka.melo.audio',
|
||||||
androidNotificationChannelName: 'Melo Wiedergabe',
|
androidNotificationChannelName: 'Melo Wiedergabe',
|
||||||
androidNotificationOngoing: true,
|
androidStopForegroundOnPause: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
MeloLogger().zustand('start_ok', {'db': 'ok', 'audio': 'ok'});
|
MeloLogger().zustand('start_ok', {'db': 'ok', 'audio': 'ok'});
|
||||||
@@ -44,6 +45,9 @@ void main() async {
|
|||||||
// Speicherzugriff für Musik-Scan (READ_MEDIA_AUDIO / Storage)
|
// Speicherzugriff für Musik-Scan (READ_MEDIA_AUDIO / Storage)
|
||||||
await MusikScanner().frageSpeicherZugriff();
|
await MusikScanner().frageSpeicherZugriff();
|
||||||
|
|
||||||
|
// Auto-Scan: Musikordner beim Start scannen + periodisch alle 3h (Issue #6)
|
||||||
|
_starteAutoScan();
|
||||||
|
|
||||||
// POST_NOTIFICATIONS für Android 13+ (Notifications für Downloads, Player)
|
// POST_NOTIFICATIONS für Android 13+ (Notifications für Downloads, Player)
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
await Permission.notification.request();
|
await Permission.notification.request();
|
||||||
@@ -55,6 +59,25 @@ void main() async {
|
|||||||
runApp(const MeloApp());
|
runApp(const MeloApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Führt Musik-Scan beim Start aus + Timer.periodic alle 3 Stunden (Issue #6)
|
||||||
|
void _starteAutoScan() {
|
||||||
|
// Sofort beim Start scannen (asynchron, blockiert nicht)
|
||||||
|
MusikScanner().scanneMusikOrdner().then((songs) {
|
||||||
|
MeloLogger().zustand('auto_scan_start', {'gefunden': songs.length});
|
||||||
|
}).catchError((e) {
|
||||||
|
MeloLogger().fehler('auto_scan_start', e);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Periodischer Scan alle 3 Stunden
|
||||||
|
Timer.periodic(const Duration(hours: 3), (_) {
|
||||||
|
MusikScanner().scanneMusikOrdner().then((songs) {
|
||||||
|
MeloLogger().zustand('auto_scan_periodisch', {'gefunden': songs.length});
|
||||||
|
}).catchError((e) {
|
||||||
|
MeloLogger().fehler('auto_scan_periodisch', e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Führt Cloud-Auto-Sync beim App-Start aus, falls konfiguriert
|
/// Führt Cloud-Auto-Sync beim App-Start aus, falls konfiguriert
|
||||||
Future<void> _starteAutoSyncFallsNoetig() async {
|
Future<void> _starteAutoSyncFallsNoetig() async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user