mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: playback not moving to next track after a track ends
This commit is contained in:
parent
19d0ddcdd9
commit
27e8acbfe7
@ -14,7 +14,7 @@ class ProxyPlaylist {
|
||||
List.castFrom<dynamic, Map<String, dynamic>>(
|
||||
json['tracks'] ?? <Map<String, dynamic>>[],
|
||||
).map(_makeAppropriateTrack).toSet(),
|
||||
json['active'] as int,
|
||||
json['active'] as int?,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@ -214,7 +213,9 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
|
||||
}) async {
|
||||
tracks = blacklist.filter(tracks).toList() as List<Track>;
|
||||
final addableTrack = await SpotubeTrack.fetchFromTrack(
|
||||
tracks.elementAt(initialIndex), preferences);
|
||||
tracks.elementAt(initialIndex),
|
||||
preferences,
|
||||
);
|
||||
|
||||
state = state.copyWith(
|
||||
tracks: mergeTracks([addableTrack], tracks),
|
||||
@ -389,6 +390,8 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
|
||||
|
||||
@override
|
||||
onInit() {
|
||||
if (state.tracks.isEmpty) return null;
|
||||
|
||||
return load(
|
||||
state.tracks,
|
||||
initialIndex: state.active ?? 0,
|
||||
|
@ -40,9 +40,13 @@ class MkPlayerWithState extends Player {
|
||||
_playerStateStream.add(AudioPlaybackState.paused);
|
||||
}
|
||||
}),
|
||||
streams.completed.listen((event) async {
|
||||
streams.position.listen((position) async {
|
||||
final isComplete = state.duration != Duration.zero &&
|
||||
position != Duration.zero &&
|
||||
state.duration.inSeconds == position.inSeconds;
|
||||
|
||||
if (!isComplete || _playlist == null) return;
|
||||
_playerStateStream.add(AudioPlaybackState.completed);
|
||||
if (!event || _playlist == null) return;
|
||||
|
||||
if (loopMode == PlaylistMode.single) {
|
||||
await super.open(_playlist!.medias[_playlist!.index], play: true);
|
||||
|
Loading…
Reference in New Issue
Block a user