From 8a13f96dbb14be0d1d80577816246109c42b7983 Mon Sep 17 00:00:00 2001 From: Gustl22 Date: Thu, 24 Nov 2022 00:46:04 +0100 Subject: [PATCH] feat: log path and url of sources (#1334) --- packages/audioplayers/lib/src/source.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/audioplayers/lib/src/source.dart b/packages/audioplayers/lib/src/source.dart index d5d09c195..b81fda3a2 100644 --- a/packages/audioplayers/lib/src/source.dart +++ b/packages/audioplayers/lib/src/source.dart @@ -13,23 +13,35 @@ abstract class Source { /// This can be an audio file to be downloaded or an audio stream. class UrlSource extends Source { final String url; + UrlSource(this.url); @override Future setOnPlayer(AudioPlayer player) { return player.setSourceUrl(url); } + + @override + String toString() { + return 'UrlSource(url: $url)'; + } } /// Source representing the absolute path of a file in the user's device. class DeviceFileSource extends Source { final String path; + DeviceFileSource(this.path); @override Future setOnPlayer(AudioPlayer player) { return player.setSourceDeviceFile(path); } + + @override + String toString() { + return 'DeviceFileSource(path: $path)'; + } } /// Source representing the path of an application asset in your Flutter @@ -38,12 +50,18 @@ class DeviceFileSource extends Source { /// instance. class AssetSource extends Source { final String path; + AssetSource(this.path); @override Future setOnPlayer(AudioPlayer player) { return player.setSourceAsset(path); } + + @override + String toString() { + return 'AssetSource(path: $path)'; + } } /// Source containing the actual bytes of the media to be played. @@ -51,6 +69,7 @@ class AssetSource extends Source { /// This is currently only supported for Android (SDK >= 23). class BytesSource extends Source { final Uint8List bytes; + BytesSource(this.bytes); @override