mirror of
https://github.com/stonega/tsacdop
synced 2025-02-17 20:10:37 +01:00
Fix playlist init error.
This commit is contained in:
parent
c2e0330cde
commit
2619787c8d
@ -278,20 +278,22 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
if (state[1] != '') {
|
if (state[1] != '') {
|
||||||
var episode = await _dbHelper.getRssItemWithUrl(state[1]);
|
var episode = await _dbHelper.getRssItemWithUrl(state[1]);
|
||||||
if ((!_playlist.isQueue && _playlist.contains(episode)) ||
|
if ((!_playlist.isQueue && _playlist.contains(episode)) ||
|
||||||
(_playlist.isQueue && _queue.episodes.first == episode)) {
|
(_playlist.isQueue &&
|
||||||
|
_queue.isNotEmpty &&
|
||||||
|
_queue.episodes.first == episode)) {
|
||||||
_episode = episode;
|
_episode = episode;
|
||||||
_lastPosition = int.parse(state[2] ?? '0');
|
_lastPosition = int.parse(state[2] ?? '0');
|
||||||
} else {
|
} else {
|
||||||
_episode = _playlist.episodes.first;
|
_episode = _playlist.isNotEmpty ? _playlist.episodes.first : null;
|
||||||
_lastPosition = 0;
|
_lastPosition = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_episode = _playlist.episodes.first;
|
_episode = _playlist.isNotEmpty ? _playlist.episodes.first : null;
|
||||||
_lastPosition = 0;
|
_lastPosition = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_playlist = _playlists.first;
|
_playlist = _playlists.first;
|
||||||
_episode = _playlist.episodes.first;
|
_episode = _playlist.isNotEmpty ? _playlist.episodes?.first : null;
|
||||||
_lastPosition = 0;
|
_lastPosition = 0;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -311,8 +313,9 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
Future<void> playFromLastPosition() async {
|
Future<void> playFromLastPosition() async {
|
||||||
if (_playlist.episodes.isNotEmpty) {
|
if (_playlist.episodes.isNotEmpty) {
|
||||||
await _playlist.getPlaylist();
|
await _playlist.getPlaylist();
|
||||||
if (_episode == null || !_playlist.episodes.contains(_episode))
|
if (_episode == null || !_playlist.episodes.contains(_episode)) {
|
||||||
_episode = _playlist.episodes.first;
|
_episode = _playlist.isNotEmpty ? _playlist.episodes.first : null;
|
||||||
|
}
|
||||||
_audioState = AudioProcessingState.none;
|
_audioState = AudioProcessingState.none;
|
||||||
_backgroundAudioDuration = 0;
|
_backgroundAudioDuration = 0;
|
||||||
_backgroundAudioPosition = 0;
|
_backgroundAudioPosition = 0;
|
||||||
@ -332,7 +335,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
_playlist = p;
|
_playlist = p;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
if (playlist.episodeList.isNotEmpty) {
|
if (playlist.isNotEmpty) {
|
||||||
if (playerRunning) {
|
if (playerRunning) {
|
||||||
AudioService.customAction('setIsQueue', playlist.name == 'Queue');
|
AudioService.customAction('setIsQueue', playlist.name == 'Queue');
|
||||||
AudioService.customAction('changeQueue',
|
AudioService.customAction('changeQueue',
|
||||||
@ -716,7 +719,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
];
|
];
|
||||||
if (_playlist == playlist && !_playerRunning) {
|
if (_playlist == playlist && !_playerRunning) {
|
||||||
_playlist = _queue;
|
_playlist = _queue;
|
||||||
_episode = _queue.episodes.first;
|
_episode = _playlist.isNotEmpty ? _queue.episodes.first : null;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
_savePlaylists();
|
_savePlaylists();
|
||||||
@ -764,8 +767,10 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
delFromPlaylist(e);
|
delFromPlaylist(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
playlist.clear();
|
playlist.clear();
|
||||||
|
if (_playlist.isQueue) _episode = null;
|
||||||
|
}
|
||||||
updatePlaylist(playlist, updateEpisodes: false);
|
updatePlaylist(playlist, updateEpisodes: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -943,9 +948,6 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save player state.
|
|
||||||
Future<void> _savePlayerPosiont() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AudioPlayerTask extends BackgroundAudioTask {
|
class AudioPlayerTask extends BackgroundAudioTask {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user