From 4d49bf086e08eddc531f379886f895e95974f059 Mon Sep 17 00:00:00 2001 From: stonegate Date: Sun, 14 Jun 2020 16:03:03 +0800 Subject: [PATCH] Change playlist icon Move versioncode to pubspec Check if skip in erroe state --- android/app/build.gradle | 2 +- lib/home/playlist.dart | 22 +++++++++++++++++----- lib/state/audiostate.dart | 13 ++++++++++--- pubspec.yaml | 2 +- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 2f45f64..3133295 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -49,7 +49,7 @@ android { applicationId "com.stonegate.tsacdop" minSdkVersion 19 targetSdkVersion 29 - versionCode 17 + versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/lib/home/playlist.dart b/lib/home/playlist.dart index 79e4430..e1995b5 100644 --- a/lib/home/playlist.dart +++ b/lib/home/playlist.dart @@ -12,6 +12,7 @@ import '../state/audiostate.dart'; import '../type/episodebrief.dart'; import '../util/context_extension.dart'; import '../util/custompaint.dart'; +import '../util/colorize.dart'; class PlaylistPage extends StatefulWidget { @override @@ -306,6 +307,9 @@ class _DismissibleContainerState extends State { @override Widget build(BuildContext context) { var audio = Provider.of(context, listen: false); + Color _c = (Theme.of(context).brightness == Brightness.light) + ? widget.episode.primaryColor.colorizedark() + : widget.episode.primaryColor.colorizeLight(); return AnimatedContainer( duration: Duration(milliseconds: 300), alignment: Alignment.center, @@ -381,10 +385,18 @@ class _DismissibleContainerState extends State { overflow: TextOverflow.ellipsis, ), ), - leading: CircleAvatar( - //backgroundColor: _c.withOpacity(0.5), - backgroundImage: - FileImage(File("${widget.episode.imagePath}")), + leading: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.unfold_more, color: _c), + CircleAvatar( + //backgroundColor: _c.withOpacity(0.5), + backgroundImage: + FileImage(File("${widget.episode.imagePath}")), + ), + ], ), subtitle: Container( padding: EdgeInsets.only(top: 5, bottom: 10), @@ -418,7 +430,7 @@ class _DismissibleContainerState extends State { ], ), ), - trailing: Icon(Icons.menu), + //trailing: Icon(Icons.menu), ), // Divider( // height: 2, diff --git a/lib/state/audiostate.dart b/lib/state/audiostate.dart index 5f780e7..784d37d 100644 --- a/lib/state/audiostate.dart +++ b/lib/state/audiostate.dart @@ -422,7 +422,7 @@ class AudioPlayerNotifier extends ChangeNotifier { } playNext() async { - AudioService.skipToNext(); + await AudioService.skipToNext(); } addToPlaylist(EpisodeBrief episode) async { @@ -678,7 +678,7 @@ class AudioPlayerTask extends BackgroundAudioTask { }); var eventSubscription = _audioPlayer.playbackEventStream.listen((event) { if (event.playbackError != null) { - _setState(state: BasicPlaybackState.error); + _setState(state: _skipState ?? BasicPlaybackState.error); } BasicPlaybackState state; if (event.buffering) { @@ -818,7 +818,14 @@ class AudioPlayerTask extends BackgroundAudioTask { @override void onClick(MediaButton button) { - playPause(); + if (button == MediaButton.media) + playPause(); + else if (button == MediaButton.next) + _audioPlayer.seek(Duration( + milliseconds: AudioServiceBackground.state.position + 30 * 1000)); + else if (button == MediaButton.previous) + _audioPlayer.seek(Duration( + milliseconds: AudioServiceBackground.state.position - 10 * 1000)); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 6ac4646..a57e09e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: tsacdop description: An easy-use podacasts player. -version: 0.3.4 +version: 0.3.4+17 environment: sdk: ">=2.6.0 <3.0.0"