summaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens/media/media_player.dart
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2024-01-03 18:14:12 -0500
committerScott Murray <scott.murray@konsulko.com>2024-01-03 18:23:55 -0500
commit2d395f4431ba4aa5055d02437463588f4d4c8127 (patch)
tree977be67fcfab0edac1e6e03f77af6e7be0dc8931 /lib/presentation/screens/media/media_player.dart
parent4742fde5c48726357cc8db06d237e9db6c3df608 (diff)
Initial mediaplayer implementation
Notable changes: - Added dart_mpd package as a dependency. - Added MPD client class and associated provider. - Added MPD client configuration to the configuration file for potential usecases where MPD may not be available locally. - Added playlist, play state, art, etc. providers for use in the mediaplayer front end UI. - Reworked MediaPlayer classes to wire up MPD client backend. - Removed volume slider from the bottom of the media pages to make more room for playlist / preset tables, as only being able to show 3 entries in each was not usable in practice. - Reworked media player mocked up position indicator into an actual slider control, and reworked the radio slider styling to match for better UI consistency. - Reworked media player and radio playlist / preset tables to attempt to have them layout at the same location and add an always visible scroll bar. The scroll bars currently have a layout issue with respect to scroll track size that does not seem to have an obvious fix. They are usable for now, and further investigation will be done when time permits. - Wired up play/pause button on the side volume control via a new set of play state and controller providers. Bug-AGL: SPEC-5028, SPEC-5029 Change-Id: I87efecc58b4e185443942eb32ff8148ebcd675c3 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'lib/presentation/screens/media/media_player.dart')
-rw-r--r--lib/presentation/screens/media/media_player.dart68
1 files changed, 31 insertions, 37 deletions
diff --git a/lib/presentation/screens/media/media_player.dart b/lib/presentation/screens/media/media_player.dart
index d7486c7..0dab346 100644
--- a/lib/presentation/screens/media/media_player.dart
+++ b/lib/presentation/screens/media/media_player.dart
@@ -3,38 +3,31 @@ import 'media_player_controls.dart';
import 'play_list_table.dart';
import 'segmented_buttons.dart';
-class MediaPlayer extends StatefulWidget {
+class MediaPlayer extends ConsumerStatefulWidget {
const MediaPlayer({super.key});
@override
- State<MediaPlayer> createState() => _MediaPlayerState();
+ ConsumerState<MediaPlayer> createState() => _MediaPlayerState();
}
-class _MediaPlayerState extends State<MediaPlayer> {
- String selectedNav = "Bluetooth";
- List<String> navItems = ["Bluetooth", "SD", "USB"];
-
- late String songName = "Feel Good Inc.";
-
- String tableName = "2000’s Dance Hits";
- List<PlayListModel> playList = [
- PlayListModel(songName: "Feel Good Inc.", albumName: "Gorillaz"),
- PlayListModel(
- songName: "Hips Don’t Lie", albumName: "Shakira, Wyclef Jean"),
- PlayListModel(songName: "AG1", albumName: "Paid Advertisement"),
- PlayListModel(songName: "Hey Ya!", albumName: "Outkast"),
- PlayListModel(songName: "One, Two, Step", albumName: "Ciara, Missy Elliot"),
- PlayListModel(songName: "Don’t Trust Me", albumName: "3OH!3"),
- ];
- String selectedPlayListSongName = "Feel Good Inc.";
+class _MediaPlayerState extends ConsumerState<MediaPlayer> {
+ String selectedNav = "USB";
+ List<String> navItems = ["USB", "SD", "Bluetooth"];
@override
Widget build(BuildContext context) {
- double albumArtSize = 460;
+ double albumArtSize = 400;
+ final playlistPosition = ref.watch(mediaPlayerStateProvider
+ .select((mediaplayer) => mediaplayer.playlistPosition));
+ final playlistArt = ref.watch(playlistArtProvider);
+ Uint8List art = Uint8List(0);
+ if (playlistArt.containsKey(playlistPosition)) {
+ art = playlistArt[playlistPosition]!;
+ }
+
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- //const PlayerNavigation(),
SegmentedButtons(
navItems: navItems,
selectedNav: selectedNav,
@@ -45,11 +38,20 @@ class _MediaPlayerState extends State<MediaPlayer> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- Image.asset(
- "assets/AlbumArtMedia.png",
- width: albumArtSize,
- height: albumArtSize,
- )
+ art.isNotEmpty
+ ? Image.memory(art,
+ width: albumArtSize,
+ height: albumArtSize,
+ fit: BoxFit.contain)
+ : Container(
+ width: albumArtSize,
+ height: albumArtSize,
+ color: AGLDemoColors.jordyBlueColor.withOpacity(0.2),
+ child: Icon(
+ Icons.music_note,
+ size: albumArtSize,
+ color: AGLDemoColors.jordyBlueColor,
+ ))
],
),
const SizedBox(
@@ -58,19 +60,11 @@ class _MediaPlayerState extends State<MediaPlayer> {
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- MediaPlayerControls(
- songName: songName,
- songLengthStart: "-1:23",
- songLengthStop: "5:03"),
+ MediaPlayerControls(),
const SizedBox(
- height: 72,
- ),
- PlayListTable(
- playList: playList,
- selectedPlayListSongName: selectedPlayListSongName,
- tableName: tableName,
- type: "media",
+ height: 12,
),
+ PlayListTable(),
],
)
],