80f98b3243
audio_service runs the handler in a background isolate; UI watches playbackState/mediaItem/queue streams through Riverpod. AndroidManifest gets the foreground-service media-playback permission; Info.plist gets UIBackgroundModes=audio. Bearer token attached to stream URLs via just_audio's per-source headers.
24 lines
751 B
Dart
24 lines
751 B
Dart
import 'package:audio_service/audio_service.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'app.dart';
|
|
import 'player/audio_handler.dart';
|
|
import 'player/player_provider.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final handler = await AudioService.init(
|
|
builder: () => MinstrelAudioHandler(),
|
|
config: const AudioServiceConfig(
|
|
androidNotificationChannelId: 'com.fabledsword.minstrel.audio',
|
|
androidNotificationChannelName: 'Minstrel playback',
|
|
androidNotificationOngoing: true,
|
|
),
|
|
);
|
|
runApp(ProviderScope(
|
|
overrides: [audioHandlerProvider.overrideWithValue(handler)],
|
|
child: const MinstrelApp(),
|
|
));
|
|
}
|