This commit is contained in:
Daniel Ponte 2024-10-14 11:42:48 -04:00
parent 03b9b63904
commit 9dfab9511c
8 changed files with 36 additions and 11 deletions

View file

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

View file

@ -1,7 +1,11 @@
import 'package:just_audio/just_audio.dart' as justaudio;
import 'package:just_audio_media_kit/just_audio_media_kit.dart'; import 'package:just_audio_media_kit/just_audio_media_kit.dart';
class AudioInitializer { class AudioInitializer {
late justaudio.AudioPlayer player;
void audioInit() { void audioInit() {
JustAudioMediaKit.ensureInitialized(); JustAudioMediaKit.ensureInitialized();
player = justaudio.AudioPlayer();
} }
} }

View file

@ -1,3 +1,9 @@
import 'package:just_audio/just_audio.dart' as justaudio;
class AudioInitializer { class AudioInitializer {
void audioInit() {} late justaudio.AudioPlayer player;
void audioInit() {
player = justaudio.AudioPlayer();
}
} }

View file

@ -1,3 +1,7 @@
import 'package:just_audio/just_audio.dart' as justaudio;
class AudioInitializer { class AudioInitializer {
final player = justaudio.AudioPlayer();
void audioInit() {} void audioInit() {}
} }

View file

@ -7,11 +7,12 @@ import 'audio_none.dart'
import '../pb/stillbox.pb.dart'; import '../pb/stillbox.pb.dart';
class JustAudioDriver { class JustAudioDriver {
final player = justaudio.AudioPlayer();
final initializer = AudioInitializer(); final initializer = AudioInitializer();
late justaudio.AudioPlayer player;
JustAudioDriver() { JustAudioDriver() {
initializer.audioInit(); initializer.audioInit();
player = initializer.player;
} }
Stream<justaudio.PlayerState> get playerStateStream { Stream<justaudio.PlayerState> get playerStateStream {

View file

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:just_audio/just_audio.dart'; import 'package:just_audio/just_audio.dart';
import 'package:audio_session/audio_session.dart';
import '../../views/lcd.dart'; import '../../views/lcd.dart';
import '../../views/keypad.dart'; import '../../views/keypad.dart';
import '../../views/login.dart'; import '../../views/login.dart';
@ -32,10 +33,17 @@ class _MainRadioState extends State<MainRadio> {
int queueLen = 0; int queueLen = 0;
DateFormat timeFormat = DateFormat('HH:mm'); DateFormat timeFormat = DateFormat('HH:mm');
void _setupAudioSession() async {
final session = await AudioSession.instance;
await session.configure(AudioSessionConfiguration.music());
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_setupAudioSession();
final sb = Provider.of<Stillbox>(context, listen: false); final sb = Provider.of<Stillbox>(context, listen: false);
player.player.playerStateStream.listen((event) async { player.player.playerStateStream.listen((event) async {
if (event.processingState == ProcessingState.completed && if (event.processingState == ProcessingState.completed &&
!_completer.isCompleted) { !_completer.isCompleted) {

View file

@ -18,7 +18,7 @@ packages:
source: hosted source: hosted
version: "2.11.0" version: "2.11.0"
audio_session: audio_session:
dependency: transitive dependency: "direct main"
description: description:
name: audio_session name: audio_session
sha256: "343e83bc7809fbda2591a49e525d6b63213ade10c76f15813be9aed6657b3261" sha256: "343e83bc7809fbda2591a49e525d6b63213ade10c76f15813be9aed6657b3261"
@ -412,10 +412,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7" sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.10" version: "2.2.12"
path_provider_foundation: path_provider_foundation:
dependency: transitive dependency: transitive
description: description:
@ -617,10 +617,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "14.2.4" version: "14.2.5"
web: web:
dependency: transitive dependency: transitive
description: description:
@ -649,10 +649,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: "4d45dc9069dba4619dc0ebd93c7cec5e66d8482cb625a370ac806dcc8165f2ec" sha256: e5c39a90447e7c81cfec14b041cdbd0d0916bd9ebbc7fe02ab69568be703b9bd
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.5.5" version: "5.6.0"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
@ -671,4 +671,4 @@ packages:
version: "6.5.0" version: "6.5.0"
sdks: sdks:
dart: ">=3.5.0 <4.0.0" dart: ">=3.5.0 <4.0.0"
flutter: ">=3.22.0" flutter: ">=3.24.0"

View file

@ -50,6 +50,7 @@ dependencies:
media_kit_native_event_loop: ^1.0.9 media_kit_native_event_loop: ^1.0.9
media_kit_libs_windows_audio: ^1.0.9 media_kit_libs_windows_audio: ^1.0.9
intl: ^0.19.0 intl: ^0.19.0
audio_session: ^0.1.21
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: