diff --git a/android/src/main/res/drawable-hdpi/ic_action_pause.png b/android/src/main/res/drawable-hdpi/ic_action_pause.png new file mode 100644 index 00000000..b25fe5ff Binary files /dev/null and b/android/src/main/res/drawable-hdpi/ic_action_pause.png differ diff --git a/android/src/main/res/drawable-hdpi/ic_action_play_arrow.png b/android/src/main/res/drawable-hdpi/ic_action_play_arrow.png new file mode 100644 index 00000000..2ceb7636 Binary files /dev/null and b/android/src/main/res/drawable-hdpi/ic_action_play_arrow.png differ diff --git a/android/src/main/res/drawable-hdpi/ic_action_skip_next.png b/android/src/main/res/drawable-hdpi/ic_action_skip_next.png new file mode 100644 index 00000000..459d3839 Binary files /dev/null and b/android/src/main/res/drawable-hdpi/ic_action_skip_next.png differ diff --git a/android/src/main/res/drawable-hdpi/ic_action_skip_previous.png b/android/src/main/res/drawable-hdpi/ic_action_skip_previous.png new file mode 100644 index 00000000..402364ed Binary files /dev/null and b/android/src/main/res/drawable-hdpi/ic_action_skip_previous.png differ diff --git a/android/src/main/res/drawable-hdpi/ic_action_stop.png b/android/src/main/res/drawable-hdpi/ic_action_stop.png new file mode 100644 index 00000000..e2d68be6 Binary files /dev/null and b/android/src/main/res/drawable-hdpi/ic_action_stop.png differ diff --git a/android/src/main/res/drawable-mdpi/ic_action_pause.png b/android/src/main/res/drawable-mdpi/ic_action_pause.png new file mode 100644 index 00000000..b25fe5ff Binary files /dev/null and b/android/src/main/res/drawable-mdpi/ic_action_pause.png differ diff --git a/android/src/main/res/drawable-mdpi/ic_action_play_arrow.png b/android/src/main/res/drawable-mdpi/ic_action_play_arrow.png new file mode 100644 index 00000000..2ceb7636 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/ic_action_play_arrow.png differ diff --git a/android/src/main/res/drawable-mdpi/ic_action_skip_next.png b/android/src/main/res/drawable-mdpi/ic_action_skip_next.png new file mode 100644 index 00000000..459d3839 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/ic_action_skip_next.png differ diff --git a/android/src/main/res/drawable-mdpi/ic_action_skip_previous.png b/android/src/main/res/drawable-mdpi/ic_action_skip_previous.png new file mode 100644 index 00000000..402364ed Binary files /dev/null and b/android/src/main/res/drawable-mdpi/ic_action_skip_previous.png differ diff --git a/android/src/main/res/drawable-mdpi/ic_action_stop.png b/android/src/main/res/drawable-mdpi/ic_action_stop.png new file mode 100644 index 00000000..e2d68be6 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/ic_action_stop.png differ diff --git a/android/src/main/res/drawable-xhdpi/ic_action_pause.png b/android/src/main/res/drawable-xhdpi/ic_action_pause.png new file mode 100644 index 00000000..b25fe5ff Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/ic_action_pause.png differ diff --git a/android/src/main/res/drawable-xhdpi/ic_action_play_arrow.png b/android/src/main/res/drawable-xhdpi/ic_action_play_arrow.png new file mode 100644 index 00000000..2ceb7636 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/ic_action_play_arrow.png differ diff --git a/android/src/main/res/drawable-xhdpi/ic_action_skip_next.png b/android/src/main/res/drawable-xhdpi/ic_action_skip_next.png new file mode 100644 index 00000000..459d3839 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/ic_action_skip_next.png differ diff --git a/android/src/main/res/drawable-xhdpi/ic_action_skip_previous.png b/android/src/main/res/drawable-xhdpi/ic_action_skip_previous.png new file mode 100644 index 00000000..402364ed Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/ic_action_skip_previous.png differ diff --git a/android/src/main/res/drawable-xhdpi/ic_action_stop.png b/android/src/main/res/drawable-xhdpi/ic_action_stop.png new file mode 100644 index 00000000..e2d68be6 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/ic_action_stop.png differ diff --git a/android/src/main/res/drawable-xxhdpi/ic_action_pause.png b/android/src/main/res/drawable-xxhdpi/ic_action_pause.png new file mode 100644 index 00000000..b25fe5ff Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/ic_action_pause.png differ diff --git a/android/src/main/res/drawable-xxhdpi/ic_action_play_arrow.png b/android/src/main/res/drawable-xxhdpi/ic_action_play_arrow.png new file mode 100644 index 00000000..2ceb7636 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/ic_action_play_arrow.png differ diff --git a/android/src/main/res/drawable-xxhdpi/ic_action_skip_next.png b/android/src/main/res/drawable-xxhdpi/ic_action_skip_next.png new file mode 100644 index 00000000..459d3839 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/ic_action_skip_next.png differ diff --git a/android/src/main/res/drawable-xxhdpi/ic_action_skip_previous.png b/android/src/main/res/drawable-xxhdpi/ic_action_skip_previous.png new file mode 100644 index 00000000..402364ed Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/ic_action_skip_previous.png differ diff --git a/android/src/main/res/drawable-xxhdpi/ic_action_stop.png b/android/src/main/res/drawable-xxhdpi/ic_action_stop.png new file mode 100644 index 00000000..e2d68be6 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/ic_action_stop.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/ic_action_pause.png b/android/src/main/res/drawable-xxxhdpi/ic_action_pause.png new file mode 100644 index 00000000..b25fe5ff Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/ic_action_pause.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/ic_action_play_arrow.png b/android/src/main/res/drawable-xxxhdpi/ic_action_play_arrow.png new file mode 100644 index 00000000..2ceb7636 Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/ic_action_play_arrow.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/ic_action_skip_next.png b/android/src/main/res/drawable-xxxhdpi/ic_action_skip_next.png new file mode 100644 index 00000000..459d3839 Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/ic_action_skip_next.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/ic_action_skip_previous.png b/android/src/main/res/drawable-xxxhdpi/ic_action_skip_previous.png new file mode 100644 index 00000000..402364ed Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/ic_action_skip_previous.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/ic_action_stop.png b/android/src/main/res/drawable-xxxhdpi/ic_action_stop.png new file mode 100644 index 00000000..e2d68be6 Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/ic_action_stop.png differ diff --git a/example/lib/main_group.dart b/example/lib/main_group.dart index bf7ae1a7..eb5826bf 100644 --- a/example/lib/main_group.dart +++ b/example/lib/main_group.dart @@ -27,7 +27,8 @@ class _MyAppState extends State { title: "Online", artist: "Florent Champigny", album: "OnlineAlbum", - image: MetasImage.network("https://image.shutterstock.com/image-vector/pop-music-text-art-colorful-600w-515538502.jpg"), + image: MetasImage.network( + "https://image.shutterstock.com/image-vector/pop-music-text-art-colorful-600w-515538502.jpg"), ), ), Audio( @@ -36,7 +37,8 @@ class _MyAppState extends State { title: "Rock", artist: "Florent Champigny", album: "RockAlbum", - image: MetasImage.network("https://static.radio.fr/images/broadcasts/cb/ef/2075/c300.png"), + image: MetasImage.network( + "https://static.radio.fr/images/broadcasts/cb/ef/2075/c300.png"), ), ), Audio( @@ -54,20 +56,20 @@ class _MyAppState extends State { title: "Electronic", artist: "Florent Champigny", album: "ElectronicAlbum", - image: MetasImage.network("https://i.ytimg.com/vi/nVZNy0ybegI/maxresdefault.jpg"), + image: MetasImage.network( + "https://i.ytimg.com/vi/nVZNy0ybegI/maxresdefault.jpg"), ), ), ]; - final AssetsAudioPlayerGroup _assetsAudioPlayerGroup = AssetsAudioPlayerGroup( - updateNotification: (player, playing) async { - return PlayerGroupMetas( - title: "title", - subTitle: "subtitle ${playing.length}", - image: MetasImage.asset("assets/images/country.jpg"), - ); - } - ); + final AssetsAudioPlayerGroup _assetsAudioPlayerGroup = + AssetsAudioPlayerGroup(updateNotification: (player, playing) async { + return PlayerGroupMetas( + title: "title", + subTitle: "subtitle ${playing.length}", + image: MetasImage.asset("assets/images/country.jpg"), + ); + }); //final List _subscriptions = []; @override @@ -89,7 +91,7 @@ class _MyAppState extends State { print("playerState : $playerState"); })); */ - _assetsAudioPlayerGroup.addAll(audios); + // _assetsAudioPlayerGroup.addAll(audios); super.initState(); } @@ -119,7 +121,8 @@ class _MyAppState extends State { SizedBox( height: 20, ), - _assetsAudioPlayerGroup.builderIsPlaying(builder: (context, isPlaying) { + _assetsAudioPlayerGroup.builderIsPlaying( + builder: (context, isPlaying) { if (isPlaying == null) { return SizedBox(); } diff --git a/lib/src/assets_audio_player.dart b/lib/src/assets_audio_player.dart index 85eab19e..ccf75105 100644 --- a/lib/src/assets_audio_player.dart +++ b/lib/src/assets_audio_player.dart @@ -1348,6 +1348,10 @@ class AssetsAudioPlayer { 'stop', {"id": this.id, "removeNotification": removeNotification}); } + void setBufferingOff() { + _isBuffering.add(false); + } + /// Change the current play speed (rate) of the MediaPlayer /// /// _assetsAudioPlayer.setPlaySpeed(0.4); diff --git a/lib/src/player_group.dart b/lib/src/player_group.dart index 13565c4e..9a5376ef 100644 --- a/lib/src/player_group.dart +++ b/lib/src/player_group.dart @@ -124,33 +124,43 @@ class AssetsAudioPlayerGroup { return __notificationSettings; } - Future add( - Audio audio, { + + Future add( + Playlist playlist, { LoopMode loopMode = LoopMode.none, double volume, Duration seek, double playSpeed, }) async { final player = AssetsAudioPlayer.newPlayer(); - player.open( - audio, - showNotification: false, - //not need here, we'll call another method `changeNotificationForGroup` - seek: seek, - autoStart: isPlaying.value, - //need to play() for player group - volume: volume, - loopMode: loopMode, - respectSilentMode: respectSilentMode, - playInBackground: playInBackground, - playSpeed: playSpeed, - notificationSettings: _notificationSettings, - ); - await _addPlayer(audio, player); + + + try { + await player.open( + playlist, + showNotification: false, + //not need here, we'll call another method `changeNotificationForGroup` + seek: seek, + autoStart: isPlaying.value, + //need to play() for player group + volume: volume, + loopMode: loopMode, + respectSilentMode: respectSilentMode, + playInBackground: playInBackground, + playSpeed: playSpeed, + notificationSettings: _notificationSettings, + ); + + await _addPlayer(playlist, player); + return {"data": player}; + } on PlatformException catch (e) { + return {"error": e.toString()}; + } + } - Future addAll(List