mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00

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
43 lines
1.1 KiB
Dart
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);
|
|
}
|
|
};
|
|
}
|