Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log path or url of sources #1334

Merged
merged 2 commits into from Nov 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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