spotube/lib/hooks/playback.dart
Kingkor Roy Tirtho 932462d773 sperated PlayerControl from PlayerOverlay
PlayerControls slider & duration are now vertical
hotkey init moved to Home
Player & YoutubeExplode are provided through riverpod
Playback handles all things Player used to do
GoRoutes are seperated from main to individual model file
usePaletteColor bugfix occuring for before initilizing mount
2022-03-12 19:10:21 +06:00

43 lines
1.1 KiB
Dart

import 'package:spotube/provider/Playback.dart';
Future<void> Function() useNextTrack(Playback playback) {
return () async {
try {
await playback.player.pause();
await playback.player.seek(Duration.zero);
playback.movePlaylistPositionBy(1);
} catch (e, stack) {
print("[PlayerControls.onNext()] $e");
print(stack);
}
};
}
Future<void> Function() usePreviousTrack(Playback playback) {
return () async {
try {
await playback.player.pause();
await playback.player.seek(Duration.zero);
playback.movePlaylistPositionBy(-1);
} catch (e, stack) {
print("[PlayerControls.onPrevious()] $e");
print(stack);
}
};
}
Future<void> Function([dynamic]) useTogglePlayPause(Playback playback) {
return ([key]) async {
print("CLICK CLICK");
try {
if (playback.currentTrack == null) return;
playback.isPlaying
? await playback.player.pause()
: await playback.player.play();
} catch (e, stack) {
print("[PlayPauseShortcut] $e");
print(stack);
}
};
}