From fd6e77b68960b4b107df4272cbd2da0c50245799 Mon Sep 17 00:00:00 2001 From: Prosper Shongwe <> Date: Tue, 13 Aug 2024 11:04:15 +0200 Subject: [PATCH] Support play audio from internet url --- example/lib/chat_bubble.dart | 6 +++--- lib/src/controllers/player_controller.dart | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example/lib/chat_bubble.dart b/example/lib/chat_bubble.dart index 8489a19e..566c8bd0 100644 --- a/example/lib/chat_bubble.dart +++ b/example/lib/chat_bubble.dart @@ -104,9 +104,9 @@ class _WaveBubbleState extends State { } // Prepare player with extracting waveform if index is even. controller.preparePlayer( - path: widget.path ?? file!.path, - shouldExtractWaveform: widget.index?.isEven ?? true, - ); + path: widget.path ?? file!.path, + shouldExtractWaveform: widget.index?.isEven ?? true, + isLocal: true); // Extracting waveform separately if index is odd. if (widget.index?.isOdd ?? false) { controller diff --git a/lib/src/controllers/player_controller.dart b/lib/src/controllers/player_controller.dart index 73a5cfb4..df45ed7f 100644 --- a/lib/src/controllers/player_controller.dart +++ b/lib/src/controllers/player_controller.dart @@ -110,13 +110,13 @@ class PlayerController extends ChangeNotifier { /// number of bars in the waveform. /// /// Defaults to 100. - Future preparePlayer({ - required String path, - double? volume, - bool shouldExtractWaveform = true, - int noOfSamples = 100, - }) async { - path = Uri.parse(path).path; + Future preparePlayer( + {required String path, + double? volume, + bool shouldExtractWaveform = true, + int noOfSamples = 100, + bool isLocal = true}) async { + path = isLocal ? Uri.parse(path).path : path; final isPrepared = await AudioWaveformsInterface.instance.preparePlayer( path: path, key: playerKey,