From c80625d07eaee753fd29173537bbc72f6b3be9db Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Wed, 14 Aug 2024 15:37:25 -0400 Subject: [PATCH] Fix justaudio --- lib/controller/play.dart | 14 +++-- linux/flutter/generated_plugin_registrant.cc | 4 ++ linux/flutter/generated_plugins.cmake | 2 + pubspec.lock | 56 +++++++++++++------ pubspec.yaml | 5 +- .../flutter/generated_plugin_registrant.cc | 6 +- windows/flutter/generated_plugins.cmake | 3 +- 7 files changed, 64 insertions(+), 26 deletions(-) diff --git a/lib/controller/play.dart b/lib/controller/play.dart index 2c82e10..68c25e3 100644 --- a/lib/controller/play.dart +++ b/lib/controller/play.dart @@ -1,6 +1,6 @@ -import 'dart:typed_data'; - +import 'package:flutter/services.dart'; import 'package:just_audio/just_audio.dart' as justaudio; +import 'package:just_audio_media_kit/just_audio_media_kit.dart'; //import 'package:audioplayers/audioplayers.dart' as auplay; //import 'dart:io' show Platform; @@ -14,7 +14,7 @@ class Player { late AudioDriver driver; Player() { // if (Platform.isMacOS || Platform.isIOS) { - driver = JustAudioDriver(); + driver = JustAudioDriver(); // } else { // driver = AudioPlayersDriver(); // } @@ -40,8 +40,12 @@ class AudioPlayersDriver implements AudioDriver { class JustAudioDriver implements AudioDriver { final player = justaudio.AudioPlayer(); + JustAudioDriver() { + JustAudioMediaKit.ensureInitialized(); + } + @override - Future play(Call call) { + Future play(Call call) async { player.setAudioSource(CallBytesSource(call)); return player.play(); } @@ -68,4 +72,4 @@ class CallBytesSource extends justaudio.StreamAudioSource { contentType: _call.audioType, ); } -} \ No newline at end of file +} diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index d0e7f79..1c10bb6 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,9 +7,13 @@ #include "generated_plugin_registrant.h" #include +#include void fl_register_plugins(FlPluginRegistry* registry) { 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); + g_autoptr(FlPluginRegistrar) media_kit_libs_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitLibsLinuxPlugin"); + media_kit_libs_linux_plugin_register_with_registrar(media_kit_libs_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index b29e9ba..adbd864 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,9 +4,11 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_secure_storage_linux + media_kit_libs_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + media_kit_native_event_loop ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/pubspec.lock b/pubspec.lock index 329ea45..eb23829 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + sha256: "1dceb0cf05cb63a7852c11560060e53ec2f182079a16ced6f4395c5b0875baf8" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.4" cupertino_icons: dependency: "direct main" description: @@ -110,6 +110,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_patch_package: + dependency: "direct main" + description: + name: flutter_patch_package + sha256: d24e953a5d223d53fded329e66c9037ddf3ea90f2ee85c730c4c846f287f4738 + url: "https://pub.dev" + source: hosted + version: "0.0.11" flutter_secure_storage: dependency: "direct main" description: @@ -212,10 +220,10 @@ packages: dependency: "direct main" description: name: just_audio - sha256: b7cb6bbf3750caa924d03f432ba401ec300fd90936b3f73a9b33d58b1e96286b + sha256: ee50602364ba83fa6308f5512dd560c713ec3e1f2bc75f0db43618f0d82ef71a url: "https://pub.dev" source: hosted - version: "0.9.37" + version: "0.9.39" just_audio_media_kit: dependency: "direct main" description: @@ -236,18 +244,10 @@ packages: dependency: transitive description: name: just_audio_web - sha256: "134356b0fe3d898293102b33b5fd618831ffdc72bb7a1b726140abdf22772b70" + sha256: "0edb481ad4aa1ff38f8c40f1a3576013c3420bf6669b686fe661627d49bc606c" url: "https://pub.dev" source: hosted - version: "0.4.9" - just_audio_windows: - dependency: "direct main" - description: - name: just_audio_windows - sha256: "48ab2dec79cf6097550602fe07b1a644f341450e138dc8fdc23e42ce0ed2d928" - url: "https://pub.dev" - source: hosted - version: "0.2.1" + version: "0.4.11" leak_tracker: dependency: transitive description: @@ -312,6 +312,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.10+1" + media_kit_libs_linux: + dependency: "direct main" + description: + name: media_kit_libs_linux + sha256: e186891c31daa6bedab4d74dcdb4e8adfccc7d786bfed6ad81fe24a3b3010310 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + media_kit_libs_windows_audio: + dependency: "direct main" + description: + name: media_kit_libs_windows_audio + sha256: c2fd558cc87b9d89a801141fcdffe02e338a3b21a41a18fbd63d5b221a1b8e53 + url: "https://pub.dev" + source: hosted + version: "1.0.9" + media_kit_native_event_loop: + dependency: "direct main" + description: + name: media_kit_native_event_loop + sha256: a605cf185499d14d58935b8784955a92a4bf0ff4e19a23de3d17a9106303930e + url: "https://pub.dev" + source: hosted + version: "1.0.8" meta: dependency: transitive description: @@ -428,10 +452,10 @@ packages: dependency: transitive description: name: rxdart - sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" url: "https://pub.dev" source: hosted - version: "0.27.7" + version: "0.28.0" safe_local_storage: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 41b7edd..e85c377 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,8 +43,11 @@ dependencies: flutter_secure_storage: ^9.2.2 http: ^1.2.2 just_audio: ^0.9.37 - just_audio_windows: ^0.2.1 just_audio_media_kit: ^2.0.5 + media_kit_libs_linux: any + media_kit_libs_windows_audio: any + media_kit_native_event_loop: ^1.0.8 + flutter_patch_package: '^0.0.11' dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index b6d1863..67e32e3 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,11 +7,11 @@ #include "generated_plugin_registrant.h" #include -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { FlutterSecureStorageWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); - JustAudioWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("JustAudioWindowsPlugin")); + MediaKitLibsWindowsAudioPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("MediaKitLibsWindowsAudioPluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 88514ea..c2a091d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,10 +4,11 @@ list(APPEND FLUTTER_PLUGIN_LIST flutter_secure_storage_windows - just_audio_windows + media_kit_libs_windows_audio ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + media_kit_native_event_loop ) set(PLUGIN_BUNDLED_LIBRARIES)