small cosmetics; end of playback behavior

This commit is contained in:
Moritz Weber 2022-03-05 21:43:35 +01:00
parent 41cdeaa096
commit e920f77b30
6 changed files with 62 additions and 31 deletions

View file

@ -81,23 +81,28 @@ class CurrentlyPlayingPage extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
song.title,
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
style: TEXT_BIG,
),
Text(
'${song.artist}${song.album}',
style: TEXT_SUBTITLE.copyWith(
color: Colors.grey[100],
child: SizedBox(
width: double.infinity,
height: 72.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
song.title,
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
style: TEXT_BIG,
),
),
],
Text(
'${song.artist}${song.album}',
style: TEXT_SUBTITLE.copyWith(
color: Colors.grey[100],
),
maxLines: 2,
),
],
),
),
),
const Spacer(

View file

@ -29,15 +29,21 @@ class CurrentlyPlayingBar extends StatelessWidget {
GestureDetector(
onTap: () => _onTap(context),
child: Container(
color: Colors.transparent,
color: Colors.white.withOpacity(0.02),
child: Row(
children: <Widget>[
Image(
image: getAlbumImage(song.albumArtPath),
height: 64.0,
),
Container(
width: 10.0,
Padding(
padding: const EdgeInsets.only(left: 8.0, bottom: 8.0, top: 8.0, right: 12.0),
child: Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.5),
),
child: Image(
image: getAlbumImage(song.albumArtPath),
height: 56.0,
),
),
),
Expanded(
child: Column(

View file

@ -25,13 +25,10 @@ class _NavBarState extends State<NavBar> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const CurrentlyPlayingBar(),
Container(
color: Theme.of(context).primaryColorLight,
height: 1.0,
),
BottomNavigationBar(
currentIndex: widget.currentIndex,
onTap: widget.onTap,
type: BottomNavigationBarType.fixed,
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
@ -45,6 +42,10 @@ class _NavBarState extends State<NavBar> {
icon: Icon(Icons.search),
label: 'Search',
),
// BottomNavigationBarItem(
// icon: Icon(Icons.settings),
// label: 'Settings',
// ),
],
),
],

View file

@ -105,6 +105,9 @@ class AudioPlayerDataSourceImpl implements AudioPlayerDataSource {
@override
Future<void> play() async {
if (_audioPlayer.playerState.processingState == ja.ProcessingState.completed) {
await seekToPosition(0.0);
}
_audioPlayer.play();
}
@ -438,7 +441,7 @@ class AudioPlayerDataSourceImpl implements AudioPlayerDataSource {
Future<void> seekToPosition(double position) async {
final duration = _audioPlayer.duration;
if (duration != null) {
_audioPlayer.seek(duration * position);
await _audioPlayer.seek(duration * position);
}
}
}

View file

@ -32,7 +32,7 @@ class PlatformIntegrationDataSourceImpl extends BaseAudioHandler
@override
Future<void> skipToNext() async {
_log.d('slipToNext');
_log.d('skipToNext');
_eventSubject.add(PlatformIntegrationEvent(type: PlatformIntegrationEventType.skipNext));
}
@ -81,6 +81,19 @@ class PlatformIntegrationDataSourceImpl extends BaseAudioHandler
playing: false,
));
}
} else if (pe.processingState == ProcessingState.completed) {
final timeDelta = DateTime.now().difference(pe.updateTime);
playbackState.add(playbackState.value.copyWith(
controls: [MediaControl.skipToPrevious, MediaControl.play, MediaControl.skipToNext],
systemActions: const {
MediaAction.seek,
},
processingState: AudioProcessingState.ready,
updatePosition: pe.updatePosition + timeDelta,
playing: false,
));
} else {
_log.d(pe.processingState.toString());
}
}

View file

@ -125,8 +125,11 @@ class AudioPlayerRepositoryImpl implements AudioPlayerRepository {
}
@override
Future<void> loadSongs(
{required List<Song> songs, required int initialIndex, required Playable playable}) async {
Future<void> loadSongs({
required List<Song> songs,
required int initialIndex,
required Playable playable,
}) async {
_playableSubject.add(playable);
final shuffleMode = shuffleModeStream.value;
final _initialIndex =