Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.
Open

Dev #343

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 17 additions & 14 deletions example/lib/main_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class _MyAppState extends State<MyApp> {
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(
Expand All @@ -36,7 +37,8 @@ class _MyAppState extends State<MyApp> {
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(
Expand All @@ -54,20 +56,20 @@ class _MyAppState extends State<MyApp> {
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<StreamSubscription> _subscriptions = [];

@override
Expand All @@ -89,7 +91,7 @@ class _MyAppState extends State<MyApp> {
print("playerState : $playerState");
}));
*/
_assetsAudioPlayerGroup.addAll(audios);
// _assetsAudioPlayerGroup.addAll(audios);
super.initState();
}

Expand Down Expand Up @@ -119,7 +121,8 @@ class _MyAppState extends State<MyApp> {
SizedBox(
height: 20,
),
_assetsAudioPlayerGroup.builderIsPlaying(builder: (context, isPlaying) {
_assetsAudioPlayerGroup.builderIsPlaying(
builder: (context, isPlaying) {
if (isPlaying == null) {
return SizedBox();
}
Expand Down
4 changes: 4 additions & 0 deletions lib/src/assets_audio_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
58 changes: 32 additions & 26 deletions lib/src/player_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,33 +124,43 @@ class AssetsAudioPlayerGroup {
return __notificationSettings;
}

Future<void> add(
Audio audio, {

Future<Map> 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<void> addAll(List<Audio> audios) async {
for (Audio audio in audios) await add(audio);
Future<void> addAll(List<Playlist> audios) async {
for (Playlist audio in audios) await add(audio);
}

Future<void> removeAudio(Audio audio) async {
Expand All @@ -163,7 +173,7 @@ class AssetsAudioPlayerGroup {
await _onPlayersChanged();
}

Future<void> _addPlayer(Audio audio, AssetsAudioPlayer player) async {
Future<void> _addPlayer(Playlist audios, AssetsAudioPlayer player) async {
StreamSubscription finishedSubscription;
finishedSubscription = player.playlistFinished.listen((finished) {
if (finished) {
Expand All @@ -172,13 +182,9 @@ class AssetsAudioPlayerGroup {
_removePlayer(player);
}
});
_subscriptions.add(finishedSubscription);
_audiosWithPlayers[audio] = player;

player.onErrorDo = (errorHandler) {
_onPlayerError(errorHandler);
};

_subscriptions.add(finishedSubscription);
_audiosWithPlayers[audios.audios[0]] = player;
await _onPlayersChanged();
}

Expand Down