diff --git a/README.md b/README.md index 324a88eb0..175b22532 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ For a Local File, add the `isLocal` parameter: ``` To play a file in the form of a data buffer (Uint8List), use the method `playBytes`. -This currently is not supported when calling from `audio_cache` and only works for Android (requiring API >= 23). +This currently only works for Android (requiring API >= 23). ```dart playLocal() async { diff --git a/android/src/main/java/xyz/luan/audioplayers/WrappedMediaPlayer.java b/android/src/main/java/xyz/luan/audioplayers/WrappedMediaPlayer.java index 506c37e4a..101f8fadb 100644 --- a/android/src/main/java/xyz/luan/audioplayers/WrappedMediaPlayer.java +++ b/android/src/main/java/xyz/luan/audioplayers/WrappedMediaPlayer.java @@ -200,8 +200,7 @@ void play(Context context) { this.player = createPlayer(context); if (dataSource != null) { setMediaSource(dataSource); - } - else { + } else { this.setSource(url); } this.player.prepareAsync(); diff --git a/lib/audio_cache.dart b/lib/audio_cache.dart index d7d2e9bd4..006b92438 100644 --- a/lib/audio_cache.dart +++ b/lib/audio_cache.dart @@ -128,13 +128,15 @@ class AudioCache { /// Plays the given [fileName] by a byte source. /// /// This is no different than calling this API via AudioPlayer, except it will return (if applicable) the cached AudioPlayer. - Future playBytes(Uint8List fileBytes, - {double volume = 1.0, - bool isNotification, - PlayerMode mode = PlayerMode.MEDIA_PLAYER, - bool loop = false, - bool stayAwake, - bool recordingActive}) async { + Future playBytes( + Uint8List fileBytes, { + double volume = 1.0, + bool isNotification, + PlayerMode mode = PlayerMode.MEDIA_PLAYER, + bool loop = false, + bool stayAwake, + bool recordingActive, + }) async { AudioPlayer player = _player(mode); if (loop) { diff --git a/lib/audioplayers.dart b/lib/audioplayers.dart index 6fc6e6b53..97cbcc5a2 100644 --- a/lib/audioplayers.dart +++ b/lib/audioplayers.dart @@ -358,7 +358,8 @@ class AudioPlayer { /// `callback` is invoked on a background isolate and will not have direct /// access to the state held by the main isolate (or any other isolate). Future monitorNotificationStateChanges( - void Function(AudioPlayerState value) callback) async { + void Function(AudioPlayerState value) callback, + ) async { if (callback == null) { throw ArgumentError.notNull('callback'); } @@ -412,13 +413,15 @@ class AudioPlayer { /// Plays audio in the form of a byte array. /// /// respectSilence and stayAwake are not implemented on macOS. - Future playBytes(Uint8List bytes, - {double volume = 1.0, - // position must be null by default to be compatible with radio streams - Duration position, - bool respectSilence = false, - bool stayAwake = false, - bool recordingActive = false}) async { + Future playBytes( + Uint8List bytes, { + double volume = 1.0, + // position must be null by default to be compatible with radio streams + Duration position, + bool respectSilence = false, + bool stayAwake = false, + bool recordingActive = false, + }) async { volume ??= 1.0; respectSilence ??= false; stayAwake ??= false; @@ -535,17 +538,18 @@ class AudioPlayer { /// Sets the notification bar for lock screen and notification area in iOS for now. /// /// Specify atleast title - Future setNotification( - {String title, - String albumTitle, - String artist, - String imageUrl, - Duration forwardSkipInterval = Duration.zero, - Duration backwardSkipInterval = Duration.zero, - Duration duration = Duration.zero, - Duration elapsedTime = Duration.zero, - bool hasPreviousTrack = false, - bool hasNextTrack = false}) { + Future setNotification({ + String title, + String albumTitle, + String artist, + String imageUrl, + Duration forwardSkipInterval = Duration.zero, + Duration backwardSkipInterval = Duration.zero, + Duration duration = Duration.zero, + Duration elapsedTime = Duration.zero, + bool hasPreviousTrack = false, + bool hasNextTrack = false, + }) { return _invokeMethod('setNotification', { 'title': title ?? '', 'albumTitle': albumTitle ?? '', @@ -568,11 +572,16 @@ class AudioPlayer { /// this method. /// /// respectSilence is not implemented on macOS. - Future setUrl(String url, - {bool isLocal: false, bool respectSilence = false}) { + Future setUrl( + String url, { + bool isLocal: false, + bool respectSilence = false, + }) { isLocal = isLocalUrl(url); - return _invokeMethod('setUrl', - {'url': url, 'isLocal': isLocal, 'respectSilence': respectSilence}); + return _invokeMethod( + 'setUrl', + {'url': url, 'isLocal': isLocal, 'respectSilence': respectSilence}, + ); } /// Get audio duration after setting url.