From 9dfab9511c03acfbb64c8c1cab204cd035088469 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Mon, 14 Oct 2024 11:42:48 -0400 Subject: [PATCH] wip --- android/gradle/wrapper/gradle-wrapper.properties | 3 ++- lib/views/audio_mediakit.dart | 4 ++++ lib/views/audio_none.dart | 8 +++++++- lib/views/audio_web.dart | 4 ++++ lib/views/play.dart | 3 ++- lib/views/radio.dart | 8 ++++++++ pubspec.lock | 16 ++++++++-------- pubspec.yaml | 1 + 8 files changed, 36 insertions(+), 11 deletions(-) diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e1ca574..3499ded 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip diff --git a/lib/views/audio_mediakit.dart b/lib/views/audio_mediakit.dart index a7f2476..b598995 100644 --- a/lib/views/audio_mediakit.dart +++ b/lib/views/audio_mediakit.dart @@ -1,7 +1,11 @@ +import 'package:just_audio/just_audio.dart' as justaudio; import 'package:just_audio_media_kit/just_audio_media_kit.dart'; class AudioInitializer { + late justaudio.AudioPlayer player; + void audioInit() { JustAudioMediaKit.ensureInitialized(); + player = justaudio.AudioPlayer(); } } diff --git a/lib/views/audio_none.dart b/lib/views/audio_none.dart index 6c6f840..ae28a2e 100644 --- a/lib/views/audio_none.dart +++ b/lib/views/audio_none.dart @@ -1,3 +1,9 @@ +import 'package:just_audio/just_audio.dart' as justaudio; + class AudioInitializer { - void audioInit() {} + late justaudio.AudioPlayer player; + + void audioInit() { + player = justaudio.AudioPlayer(); + } } diff --git a/lib/views/audio_web.dart b/lib/views/audio_web.dart index 6c6f840..bafee4d 100644 --- a/lib/views/audio_web.dart +++ b/lib/views/audio_web.dart @@ -1,3 +1,7 @@ +import 'package:just_audio/just_audio.dart' as justaudio; + class AudioInitializer { + final player = justaudio.AudioPlayer(); + void audioInit() {} } diff --git a/lib/views/play.dart b/lib/views/play.dart index 3da4d50..c919a93 100644 --- a/lib/views/play.dart +++ b/lib/views/play.dart @@ -7,11 +7,12 @@ import 'audio_none.dart' import '../pb/stillbox.pb.dart'; class JustAudioDriver { - final player = justaudio.AudioPlayer(); final initializer = AudioInitializer(); + late justaudio.AudioPlayer player; JustAudioDriver() { initializer.audioInit(); + player = initializer.player; } Stream get playerStateStream { diff --git a/lib/views/radio.dart b/lib/views/radio.dart index c321cbe..22e1c9c 100644 --- a/lib/views/radio.dart +++ b/lib/views/radio.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:just_audio/just_audio.dart'; +import 'package:audio_session/audio_session.dart'; import '../../views/lcd.dart'; import '../../views/keypad.dart'; import '../../views/login.dart'; @@ -32,10 +33,17 @@ class _MainRadioState extends State { int queueLen = 0; DateFormat timeFormat = DateFormat('HH:mm'); + void _setupAudioSession() async { + final session = await AudioSession.instance; + await session.configure(AudioSessionConfiguration.music()); + } + @override void initState() { super.initState(); + _setupAudioSession(); final sb = Provider.of(context, listen: false); + player.player.playerStateStream.listen((event) async { if (event.processingState == ProcessingState.completed && !_completer.isCompleted) { diff --git a/pubspec.lock b/pubspec.lock index a04f270..3ff5e24 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -18,7 +18,7 @@ packages: source: hosted version: "2.11.0" audio_session: - dependency: transitive + dependency: "direct main" description: name: audio_session sha256: "343e83bc7809fbda2591a49e525d6b63213ade10c76f15813be9aed6657b3261" @@ -412,10 +412,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7" + sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a url: "https://pub.dev" source: hosted - version: "2.2.10" + version: "2.2.12" path_provider_foundation: dependency: transitive description: @@ -617,10 +617,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "14.2.5" web: dependency: transitive description: @@ -649,10 +649,10 @@ packages: dependency: transitive description: name: win32 - sha256: "4d45dc9069dba4619dc0ebd93c7cec5e66d8482cb625a370ac806dcc8165f2ec" + sha256: e5c39a90447e7c81cfec14b041cdbd0d0916bd9ebbc7fe02ab69568be703b9bd url: "https://pub.dev" source: hosted - version: "5.5.5" + version: "5.6.0" xdg_directories: dependency: transitive description: @@ -671,4 +671,4 @@ packages: version: "6.5.0" sdks: dart: ">=3.5.0 <4.0.0" - flutter: ">=3.22.0" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index c9c515f..3d4208c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,6 +50,7 @@ dependencies: media_kit_native_event_loop: ^1.0.9 media_kit_libs_windows_audio: ^1.0.9 intl: ^0.19.0 + audio_session: ^0.1.21 dev_dependencies: flutter_test: