0.6.7 - shows in search, album art resolution
This commit is contained in:
parent
babd12bae2
commit
c3a26b0e3b
18 changed files with 369 additions and 28 deletions
|
@ -51,6 +51,9 @@ class Cache {
|
|||
@JsonKey(defaultValue: 0)
|
||||
int lastUpdateCheck;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
bool wakelock = false;
|
||||
|
||||
Cache({this.libraryTracks});
|
||||
|
||||
//Wrapper to test if track is favorite against cache
|
||||
|
|
|
@ -392,7 +392,7 @@ class Playlist {
|
|||
id: json['PLAYLIST_ID'].toString(),
|
||||
title: json['TITLE'],
|
||||
trackCount: json['NB_SONG']??songsJson['total'],
|
||||
image: ImageDetails.fromPrivateString(json['PLAYLIST_PICTURE'], type: 'playlist'),
|
||||
image: ImageDetails.fromPrivateString(json['PLAYLIST_PICTURE'], type: json['PICTURE_TYPE']),
|
||||
fans: json['NB_FAN'],
|
||||
duration: Duration(seconds: json['DURATION']??0),
|
||||
description: json['DESCRIPTION'],
|
||||
|
@ -464,7 +464,7 @@ class ImageDetails {
|
|||
|
||||
//JSON
|
||||
factory ImageDetails.fromPrivateString(String art, {String type='cover'}) => ImageDetails(
|
||||
fullUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/1400x1400-000000-80-0-0.jpg',
|
||||
fullUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/1000x1000-000000-80-0-0.jpg',
|
||||
thumbUrl: 'https://e-cdns-images.dzcdn.net/images/$type/$art/140x140-000000-80-0-0.jpg'
|
||||
);
|
||||
factory ImageDetails.fromPrivateJson(Map<dynamic, dynamic> json) => ImageDetails.fromPrivateString(
|
||||
|
@ -481,22 +481,28 @@ class SearchResults {
|
|||
List<Album> albums;
|
||||
List<Artist> artists;
|
||||
List<Playlist> playlists;
|
||||
List<Show> shows;
|
||||
List<ShowEpisode> episodes;
|
||||
|
||||
SearchResults({this.tracks, this.albums, this.artists, this.playlists});
|
||||
SearchResults({this.tracks, this.albums, this.artists, this.playlists, this.shows, this.episodes});
|
||||
|
||||
//Check if no search results
|
||||
bool get empty {
|
||||
return ((tracks == null || tracks.length == 0) &&
|
||||
(albums == null || albums.length == 0) &&
|
||||
(artists == null || artists.length == 0) &&
|
||||
(playlists == null || playlists.length == 0));
|
||||
(playlists == null || playlists.length == 0) &&
|
||||
(shows == null || shows.length == 0) &&
|
||||
(episodes == null || episodes.length == 0));
|
||||
}
|
||||
|
||||
factory SearchResults.fromPrivateJson(Map<dynamic, dynamic> json) => SearchResults(
|
||||
tracks: json['TRACK']['data'].map<Track>((dynamic data) => Track.fromPrivateJson(data)).toList(),
|
||||
albums: json['ALBUM']['data'].map<Album>((dynamic data) => Album.fromPrivateJson(data)).toList(),
|
||||
artists: json['ARTIST']['data'].map<Artist>((dynamic data) => Artist.fromPrivateJson(data)).toList(),
|
||||
playlists: json['PLAYLIST']['data'].map<Playlist>((dynamic data) => Playlist.fromPrivateJson(data)).toList()
|
||||
playlists: json['PLAYLIST']['data'].map<Playlist>((dynamic data) => Playlist.fromPrivateJson(data)).toList(),
|
||||
shows: json['SHOW']['data'].map<Show>((dynamic data) => Show.fromPrivateJson(data)).toList(),
|
||||
episodes: json['EPISODE']['data'].map<ShowEpisode>((dynamic data) => ShowEpisode.fromPrivateJson(data)).toList()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -897,8 +903,10 @@ class ShowEpisode {
|
|||
String url;
|
||||
Duration duration;
|
||||
String publishedDate;
|
||||
//Might not be fully available
|
||||
Show show;
|
||||
|
||||
ShowEpisode({this.id, this.title, this.description, this.url, this.duration, this.publishedDate});
|
||||
ShowEpisode({this.id, this.title, this.description, this.url, this.duration, this.publishedDate, this.show});
|
||||
|
||||
String get durationString => "${duration.inMinutes}:${duration.inSeconds.remainder(60).toString().padLeft(2, '0')}";
|
||||
|
||||
|
@ -917,7 +925,7 @@ class ShowEpisode {
|
|||
},
|
||||
displayDescription: description,
|
||||
duration: duration,
|
||||
artUri: show.art.full
|
||||
artUri: show.art.full,
|
||||
);
|
||||
}
|
||||
factory ShowEpisode.fromMediaItem(MediaItem mi) {
|
||||
|
@ -927,6 +935,7 @@ class ShowEpisode {
|
|||
description: mi.displayDescription,
|
||||
url: mi.extras['showUrl'],
|
||||
duration: mi.duration,
|
||||
show: Show.fromPrivateJson(mi.extras['show'])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -937,7 +946,8 @@ class ShowEpisode {
|
|||
description: json['EPISODE_DESCRIPTION'],
|
||||
url: json['EPISODE_DIRECT_STREAM_URL'],
|
||||
duration: Duration(seconds: int.parse(json['DURATION'].toString())),
|
||||
publishedDate: json['EPISODE_PUBLISHED_TIMESTAMP']
|
||||
publishedDate: json['EPISODE_PUBLISHED_TIMESTAMP'],
|
||||
show: Show.fromPrivateJson(json)
|
||||
);
|
||||
|
||||
factory ShowEpisode.fromJson(Map<String, dynamic> json) => _$ShowEpisodeFromJson(json);
|
||||
|
|
|
@ -453,6 +453,9 @@ ShowEpisode _$ShowEpisodeFromJson(Map<String, dynamic> json) {
|
|||
? null
|
||||
: Duration(microseconds: json['duration'] as int),
|
||||
publishedDate: json['publishedDate'] as String,
|
||||
show: json['show'] == null
|
||||
? null
|
||||
: Show.fromJson(json['show'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -464,4 +467,5 @@ Map<String, dynamic> _$ShowEpisodeToJson(ShowEpisode instance) =>
|
|||
'url': instance.url,
|
||||
'duration': instance.duration?.inMicroseconds,
|
||||
'publishedDate': instance.publishedDate,
|
||||
'show': instance.show,
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@ class PlayerHelper {
|
|||
if (event['action'] == 'onRestore') {
|
||||
//Load queueSource from isolate
|
||||
this.queueSource = QueueSource.fromJson(event['queueSource']);
|
||||
repeatType = LoopMode.values[event['loopMode']];
|
||||
}
|
||||
if (event['action'] == 'queueEnd') {
|
||||
//If last song is played, load more queue
|
||||
|
@ -332,6 +333,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
int wifiQuality;
|
||||
QueueSource queueSource;
|
||||
Duration _lastPosition;
|
||||
LoopMode _loopMode = LoopMode.off;
|
||||
|
||||
Completer _androidAutoCallback;
|
||||
|
||||
|
@ -439,6 +441,19 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
@override
|
||||
Future<void> onSeekBackward(bool begin) async => _seekContinuously(begin, -1);
|
||||
|
||||
//Remove item from queue
|
||||
@override
|
||||
Future<void> onRemoveQueueItem(MediaItem mediaItem) async {
|
||||
int index = _queue.indexWhere((m) => m.id == mediaItem.id);
|
||||
_queue.removeAt(index);
|
||||
if (index <= _queueIndex) {
|
||||
_queueIndex--;
|
||||
}
|
||||
_audioSource.removeAt(index);
|
||||
|
||||
AudioServiceBackground.setQueue(_queue);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onSkipToNext() async {
|
||||
if (_queueIndex == _queue.length-1) return;
|
||||
|
@ -630,7 +645,8 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
}
|
||||
//Looping
|
||||
if (name == 'repeatType') {
|
||||
_player.setLoopMode(LoopMode.values[args]);
|
||||
_loopMode = LoopMode.values[args];
|
||||
_player.setLoopMode(_loopMode);
|
||||
}
|
||||
if (name == 'saveQueue')
|
||||
await this._saveQueue();
|
||||
|
@ -708,6 +724,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
'queue': _queue.map<Map<String, dynamic>>((mi) => mi.toJson()).toList(),
|
||||
'position': _player.position.inMilliseconds,
|
||||
'queueSource': (queueSource??QueueSource()).toJson(),
|
||||
'loopMode': LoopMode.values.indexOf(_loopMode??LoopMode.off)
|
||||
};
|
||||
await f.writeAsString(jsonEncode(data));
|
||||
}
|
||||
|
@ -721,6 +738,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
this._queueIndex = json['index'] ?? 0;
|
||||
this._lastPosition = Duration(milliseconds: json['position']??0);
|
||||
this.queueSource = QueueSource.fromJson(json['queueSource']??{});
|
||||
this._loopMode = LoopMode.values[(json['loopMode']??0)];
|
||||
//Restore queue
|
||||
if (_queue != null) {
|
||||
await AudioServiceBackground.setQueue(_queue);
|
||||
|
@ -731,7 +749,8 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
//Send restored queue source to ui
|
||||
AudioServiceBackground.sendCustomEvent({
|
||||
'action': 'onRestore',
|
||||
'queueSource': (queueSource??QueueSource()).toJson()
|
||||
'queueSource': (queueSource??QueueSource()).toJson(),
|
||||
'loopMode': LoopMode.values.indexOf(_loopMode)
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue