@@ -8,7 +8,6 @@ import 'package:safe_change_notifier/safe_change_notifier.dart';
88import 'package:yaru/yaru.dart' ;
99
1010import '../common/logging.dart' ;
11- import '../extensions/string_x.dart' ;
1211import 'data/local_media.dart' ;
1312import 'data/unique_media.dart' ;
1413import 'view/player_view_state.dart' ;
@@ -56,6 +55,7 @@ class PlayerManager extends BaseAudioHandler with SeekHandler {
5655 Color ? color,
5756 String ? remoteSourceArtUrl,
5857 String ? remoteSourceTitle,
58+ bool resetRemoteSource = false ,
5959 }) {
6060 final previousArtUri = mediaItem.value? .artUri;
6161 final artUri =
@@ -64,22 +64,32 @@ class PlayerManager extends BaseAudioHandler with SeekHandler {
6464 : Uri .tryParse (remoteSourceArtUrl)) ??
6565 previousArtUri;
6666
67- playerViewState.value = playerViewState.value.copyWith (
68- fullMode: fullMode,
69- showPlayerExplorer: showPlayerExplorer,
70- explorerIndex: explorerIndex,
71- color: color,
72- remoteSourceArtUrl: artUri.toString (),
73- remoteSourceTitle: remoteSourceTitle,
74- );
67+ if (resetRemoteSource) {
68+ playerViewState.value = PlayerViewState (
69+ fullMode: fullMode ?? playerViewState.value.fullMode,
70+ showPlayerExplorer:
71+ showPlayerExplorer ?? playerViewState.value.showPlayerExplorer,
72+ explorerIndex: explorerIndex ?? playerViewState.value.explorerIndex,
73+ color: color,
74+ remoteSourceArtUrl: null ,
75+ remoteSourceTitle: null ,
76+ );
77+ } else {
78+ playerViewState.value = playerViewState.value.copyWith (
79+ fullMode: fullMode,
80+ showPlayerExplorer: showPlayerExplorer,
81+ explorerIndex: explorerIndex,
82+ color: color,
83+ remoteSourceArtUrl: remoteSourceArtUrl,
84+ remoteSourceTitle: remoteSourceTitle,
85+ );
86+ }
7587
76- if (remoteSourceTitle != null ) {
77- final split = remoteSourceTitle.splitByDash;
88+ if (remoteSourceTitle != null && mediaItem.value != null ) {
7889 mediaItem.add (
79- MediaItem (
80- id: remoteSourceTitle,
90+ mediaItem.value? .copyWith (
8191 title: remoteSourceTitle,
82- artist: currentMedia? .artist ?? split.artist ,
92+ artist: currentMedia? .artist,
8393 artUri: artUri,
8494 ),
8595 );
@@ -200,13 +210,7 @@ class PlayerManager extends BaseAudioHandler with SeekHandler {
200210
201211 Future <void > setPlaylist (List <UniqueMedia > mediaList, {int index = 0 }) async {
202212 if (mediaList.isEmpty) return ;
203- updateState (
204- remoteSourceArtUrl:
205- mediaList.elementAtOrNull (index)? .artUrl? .endsWith ('.ico' ) == true
206- ? null
207- : mediaList.elementAtOrNull (index)? .artUrl,
208- remoteSourceTitle: mediaList.elementAtOrNull (index)? .title,
209- );
213+ updateState (resetRemoteSource: true );
210214 await _player.open (Playlist (mediaList, index: index));
211215 }
212216
0 commit comments