✨ Skip next & prev
This commit is contained in:
parent
7e7df4dc46
commit
5a53fc7268
@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:dismissible_page/dismissible_page.dart';
|
import 'package:dismissible_page/dismissible_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -164,12 +165,12 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
child: Slider(
|
child: Slider(
|
||||||
secondaryTrackValue: _bufferProgress.abs(),
|
secondaryTrackValue: _bufferProgress.abs(),
|
||||||
value: _draggingValue?.abs() ??
|
value: _draggingValue?.abs() ??
|
||||||
(_durationCurrent.inMilliseconds <=
|
_durationCurrent.inMilliseconds.toDouble().abs(),
|
||||||
_durationTotal.inMilliseconds
|
|
||||||
? _durationCurrent.inMilliseconds.toDouble().abs()
|
|
||||||
: 0),
|
|
||||||
min: 0,
|
min: 0,
|
||||||
max: _durationTotal.inMilliseconds.abs().toDouble(),
|
max: max(
|
||||||
|
_durationTotal.inMilliseconds.abs(),
|
||||||
|
_durationTotal.inMilliseconds.abs(),
|
||||||
|
).toDouble(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() => _draggingValue = value);
|
setState(() => _draggingValue = value);
|
||||||
},
|
},
|
||||||
@ -198,6 +199,13 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.skip_previous),
|
||||||
|
onPressed: _isFetchingActiveTrack
|
||||||
|
? null
|
||||||
|
: audioPlayer.skipToPrevious,
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 56,
|
width: 56,
|
||||||
height: 56,
|
height: 56,
|
||||||
@ -219,6 +227,12 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
_isFetchingActiveTrack ? null : _togglePlayState,
|
_isFetchingActiveTrack ? null : _togglePlayState,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const Gap(8),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.skip_next),
|
||||||
|
onPressed:
|
||||||
|
_isFetchingActiveTrack ? null : audioPlayer.skipToNext,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:rhythm_box/platform.dart';
|
import 'package:rhythm_box/platform.dart';
|
||||||
import 'package:rhythm_box/services/local_track.dart';
|
import 'package:rhythm_box/services/local_track.dart';
|
||||||
import 'package:rhythm_box/services/server/server.dart';
|
import 'package:rhythm_box/services/server/server.dart';
|
||||||
|
import 'package:rhythm_box/widgets/tracks/querying_track_info.dart';
|
||||||
import 'package:spotify/spotify.dart' hide Playlist;
|
import 'package:spotify/spotify.dart' hide Playlist;
|
||||||
import 'package:rhythm_box/services/audio_player/custom_player.dart';
|
import 'package:rhythm_box/services/audio_player/custom_player.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
@ -89,14 +89,17 @@ class RhythmAudioPlayer extends AudioPlayerInterface
|
|||||||
int get currentIndex => _mkPlayer.state.playlist.index;
|
int get currentIndex => _mkPlayer.state.playlist.index;
|
||||||
|
|
||||||
Future<void> skipToNext() async {
|
Future<void> skipToNext() async {
|
||||||
|
Get.find<QueryingTrackInfoProvider>().isQueryingTrackInfo.value = true;
|
||||||
await _mkPlayer.next();
|
await _mkPlayer.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> skipToPrevious() async {
|
Future<void> skipToPrevious() async {
|
||||||
|
Get.find<QueryingTrackInfoProvider>().isQueryingTrackInfo.value = true;
|
||||||
await _mkPlayer.previous();
|
await _mkPlayer.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> jumpTo(int index) async {
|
Future<void> jumpTo(int index) async {
|
||||||
|
Get.find<QueryingTrackInfoProvider>().isQueryingTrackInfo.value = true;
|
||||||
await _mkPlayer.jump(index);
|
await _mkPlayer.jump(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class SourcedTrackProvider extends GetxController {
|
|||||||
|
|
||||||
sourcedTrack.value = await SourcedTrack.fetchFromTrack(track: track);
|
sourcedTrack.value = await SourcedTrack.fetchFromTrack(track: track);
|
||||||
|
|
||||||
if (isCurrentTrack) query.isQueryingTrackInfo.value = false;
|
query.isQueryingTrackInfo.value = false;
|
||||||
|
|
||||||
return sourcedTrack.value;
|
return sourcedTrack.value;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,12 @@ class _BottomPlayerState extends State<BottomPlayer>
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
|
icon: const Icon(Icons.skip_next),
|
||||||
|
onPressed: _isFetchingActiveTrack
|
||||||
|
? null
|
||||||
|
: audioPlayer.skipToNext,
|
||||||
|
),
|
||||||
|
IconButton.filled(
|
||||||
icon: _isFetchingActiveTrack
|
icon: _isFetchingActiveTrack
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
|
Loading…
Reference in New Issue
Block a user