mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00

configurations for different plugin for android added adjusted platform bound opertations
42 lines
1.0 KiB
Dart
42 lines
1.0 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 {
|
|
try {
|
|
if (playback.currentTrack == null) return;
|
|
playback.isPlaying
|
|
? await playback.player.pause()
|
|
: await playback.player.play();
|
|
} catch (e, stack) {
|
|
print("[PlayPauseShortcut] $e");
|
|
print(stack);
|
|
}
|
|
};
|
|
}
|