Skip to content

Commit

Permalink
feat: log path and url of sources (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Nov 23, 2022
1 parent 2ed91fe commit 8a13f96
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/audioplayers/lib/src/source.dart
Expand Up @@ -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<void> 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<void> 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
Expand All @@ -38,19 +50,26 @@ class DeviceFileSource extends Source {
/// instance.
class AssetSource extends Source {
final String path;

AssetSource(this.path);

@override
Future<void> 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.
///
/// This is currently only supported for Android (SDK >= 23).
class BytesSource extends Source {
final Uint8List bytes;

BytesSource(this.bytes);

@override
Expand Down

0 comments on commit 8a13f96

Please sign in to comment.