use justaudio only

This commit is contained in:
Daniel 2024-08-14 14:44:18 -04:00
parent 87d5354943
commit b7af6f28bb
9 changed files with 95 additions and 120 deletions

View file

@ -1,8 +1,8 @@
import 'dart:typed_data';
import 'package:just_audio/just_audio.dart' as justaudio;
import 'package:audioplayers/audioplayers.dart' as auplay;
import 'dart:io' show Platform;
//import 'package:audioplayers/audioplayers.dart' as auplay;
//import 'dart:io' show Platform;
import '../pb/stillbox.pb.dart';
@ -13,18 +13,30 @@ abstract class AudioDriver {
class Player {
late AudioDriver driver;
Player() {
if (Platform.isMacOS || Platform.isIOS) {
// if (Platform.isMacOS || Platform.isIOS) {
driver = JustAudioDriver();
} else {
driver = AudioPlayersDriver();
}
// } else {
// driver = AudioPlayersDriver();
// }
}
Future<void> play(Call call) {
return driver.play(call);
}
// TODO make a queue
}
/*
class AudioPlayersDriver implements AudioDriver {
final player = auplay.AudioPlayer();
@override
Future<void> play(Call call) {
return player.play(auplay.BytesSource(Uint8List.fromList(call.audio)));
}
}
*/
class JustAudioDriver implements AudioDriver {
final player = justaudio.AudioPlayer();
@ -35,15 +47,6 @@ class JustAudioDriver implements AudioDriver {
}
}
class AudioPlayersDriver implements AudioDriver {
final player = auplay.AudioPlayer();
@override
Future<void> play(Call call) {
return player.play(auplay.BytesSource(Uint8List.fromList(call.audio)));
}
}
class CallBytesSource extends justaudio.StreamAudioSource {
late Uint8List _buffer;
final Call _call;

View file

@ -6,13 +6,9 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_linux/audioplayers_linux_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);

View file

@ -3,7 +3,6 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux
flutter_secure_storage_linux
)

View file

@ -6,14 +6,12 @@ import FlutterMacOS
import Foundation
import audio_session
import audioplayers_darwin
import flutter_secure_storage_macos
import just_audio
import path_provider_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))

View file

@ -1,8 +1,6 @@
PODS:
- audio_session (0.0.1):
- FlutterMacOS
- audioplayers_darwin (0.0.1):
- FlutterMacOS
- flutter_secure_storage_macos (6.1.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
@ -14,7 +12,6 @@ PODS:
DEPENDENCIES:
- audio_session (from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos`)
- audioplayers_darwin (from `Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos`)
- flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`)
@ -23,8 +20,6 @@ DEPENDENCIES:
EXTERNAL SOURCES:
audio_session:
:path: Flutter/ephemeral/.symlinks/plugins/audio_session/macos
audioplayers_darwin:
:path: Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos
flutter_secure_storage_macos:
:path: Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos
FlutterMacOS:
@ -36,7 +31,6 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
audio_session: dea1f41890dbf1718f04a56f1d6150fd50039b72
audioplayers_darwin: dcad41de4fbd0099cb3749f7ab3b0cb8f70b810c
flutter_secure_storage_macos: 59459653abe1adb92abbc8ea747d79f8d19866c9
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
just_audio: 9b67ca7b97c61cfc9784ea23cd8cc55eb226d489

View file

@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
url: "https://pub.dev"
source: hosted
version: "3.6.1"
async:
dependency: transitive
description:
@ -17,62 +25,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.21"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
sha256: "752039d6aa752597c98ec212e9759519061759e402e7da59a511f39d43aa07d2"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: de576b890befe27175c2f511ba8b742bec83765fa97c3ce4282bba46212f58e4
url: "https://pub.dev"
source: hosted
version: "5.0.0"
audioplayers_darwin:
dependency: "direct main"
description:
name: audioplayers_darwin
sha256: e507887f3ff18d8e5a10a668d7bedc28206b12e10b98347797257c6ae1019c3b
url: "https://pub.dev"
source: hosted
version: "6.0.0"
audioplayers_linux:
dependency: "direct main"
description:
name: audioplayers_linux
sha256: "3d3d244c90436115417f170426ce768856d8fe4dfc5ed66a049d2890acfa82f9"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "6834dd48dfb7bc6c2404998ebdd161f79cd3774a7e6779e1348d54a3bfdcfaa5"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: db8fc420dadf80da18e2286c18e746fb4c3b2c5adbf0c963299dde046828886d
url: "https://pub.dev"
source: hosted
version: "5.0.0"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "8605762dddba992138d476f6a0c3afd9df30ac5b96039929063eceed416795c2"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
boolean_selector:
dependency: transitive
description:
@ -121,14 +73,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
eventify:
dependency: transitive
description:
name: eventify
sha256: b829429f08586cc2001c628e7499e3e3c2493a1d895fd73b00ecb23351aa5a66
url: "https://pub.dev"
source: hosted
version: "1.0.1"
fake_async:
dependency: transitive
description:
@ -145,14 +89,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
fixnum:
dependency: "direct main"
description:
@ -256,6 +192,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
image:
dependency: transitive
description:
name: image
sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8"
url: "https://pub.dev"
source: hosted
version: "4.2.0"
js:
dependency: transitive
description:
@ -272,14 +216,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.37"
just_audio_mpv:
just_audio_media_kit:
dependency: "direct main"
description:
name: just_audio_mpv
sha256: d6e4e9fd20bfb9d2fd5e3dcd7906c90ed07f83d1d2f44f31204160821ab62fed
name: just_audio_media_kit
sha256: "7f57d317fafa04cb3e70b924e8f632ffb7eca7a97a369e1e44738ed89fbd5da1"
url: "https://pub.dev"
source: hosted
version: "0.1.7"
version: "2.0.5"
just_audio_platform_interface:
dependency: transitive
description:
@ -336,6 +280,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
@ -352,6 +304,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.11.1"
media_kit:
dependency: transitive
description:
name: media_kit
sha256: "3289062540e3b8b9746e5c50d95bd78a9289826b7227e253dff806d002b9e67a"
url: "https://pub.dev"
source: hosted
version: "1.1.10+1"
meta:
dependency: transitive
description:
@ -360,14 +320,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.15.0"
mpv_dart:
dependency: transitive
description:
name: mpv_dart
sha256: a33bd9a68439b496b7a5f36fecd3aa3cf6cbf0176ae15b9b60b12ae96e58f5a4
url: "https://pub.dev"
source: hosted
version: "0.0.1"
nested:
dependency: transitive
description:
@ -432,6 +384,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.0"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
url: "https://pub.dev"
source: hosted
version: "6.0.2"
platform:
dependency: transitive
description:
@ -472,6 +432,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.27.7"
safe_local_storage:
dependency: transitive
description:
name: safe_local_storage
sha256: ede4eb6cb7d88a116b3d3bf1df70790b9e2038bc37cb19112e381217c74d9440
url: "https://pub.dev"
source: hosted
version: "1.0.2"
sky_engine:
dependency: transitive
description: flutter
@ -549,6 +517,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
universal_platform:
dependency: transitive
description:
name: universal_platform
sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
uri_parser:
dependency: transitive
description:
name: uri_parser
sha256: "6543c9fd86d2862fac55d800a43e67c0dcd1a41677cb69c2f8edfe73bbcf1835"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
uuid:
dependency: transitive
description:
@ -613,6 +597,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
xml:
dependency: transitive
description:
name: xml
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
url: "https://pub.dev"
source: hosted
version: "6.5.0"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.22.0"

View file

@ -43,11 +43,8 @@ dependencies:
flutter_secure_storage: ^9.2.2
http: ^1.2.2
just_audio: ^0.9.37
just_audio_mpv: ^0.1.7
just_audio_windows: ^0.2.1
audioplayers: ^6.0.0
audioplayers_linux: ^4.0.0
audioplayers_darwin: ^6.0.0
just_audio_media_kit: ^2.0.5
dev_dependencies:
flutter_test:

View file

@ -6,13 +6,10 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <just_audio_windows/just_audio_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
JustAudioWindowsPluginRegisterWithRegistrar(

View file

@ -3,7 +3,6 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows
flutter_secure_storage_windows
just_audio_windows
)