mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-05-20 21:22:38 +00:00
added long press for 2x playback speed
This commit is contained in:
parent
ee07314b14
commit
3ecd3d0a14
5 changed files with 64 additions and 4 deletions
|
|
@ -171,6 +171,7 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
|
||||||
headers: _firstVid.headers));
|
headers: _firstVid.headers));
|
||||||
final ValueNotifier<double> _playbackSpeed = ValueNotifier(1.0);
|
final ValueNotifier<double> _playbackSpeed = ValueNotifier(1.0);
|
||||||
final ValueNotifier<bool> _enterFullScreen = ValueNotifier(false);
|
final ValueNotifier<bool> _enterFullScreen = ValueNotifier(false);
|
||||||
|
final ValueNotifier<bool> _isDoubleSpeed = ValueNotifier(false);
|
||||||
late final ValueNotifier<Duration> _currentPosition =
|
late final ValueNotifier<Duration> _currentPosition =
|
||||||
ValueNotifier(_streamController.geTCurrentPosition());
|
ValueNotifier(_streamController.geTCurrentPosition());
|
||||||
final ValueNotifier<Duration?> _currentTotalDuration = ValueNotifier(null);
|
final ValueNotifier<Duration?> _currentTotalDuration = ValueNotifier(null);
|
||||||
|
|
@ -977,6 +978,23 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Flexible(
|
||||||
|
fit: FlexFit.tight,
|
||||||
|
child: ValueListenableBuilder<bool>(
|
||||||
|
valueListenable: _isDoubleSpeed,
|
||||||
|
builder: (context, snapshot, _) {
|
||||||
|
return Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
children: snapshot
|
||||||
|
? [
|
||||||
|
WidgetSpan(child: Icon(Icons.fast_forward)),
|
||||||
|
TextSpan(text: " 2X"),
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
Row(children: [
|
Row(children: [
|
||||||
btnToShowChapterListDialog(
|
btnToShowChapterListDialog(
|
||||||
context,
|
context,
|
||||||
|
|
@ -1080,6 +1098,9 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
|
||||||
tempDuration: (value) {
|
tempDuration: (value) {
|
||||||
_tempPosition.value = value;
|
_tempPosition.value = value;
|
||||||
},
|
},
|
||||||
|
doubleSpeed: (value) {
|
||||||
|
_isDoubleSpeed.value = value ?? false;
|
||||||
|
},
|
||||||
)
|
)
|
||||||
: MobileControllerWidget(
|
: MobileControllerWidget(
|
||||||
videoController: _controller,
|
videoController: _controller,
|
||||||
|
|
@ -1087,6 +1108,9 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
|
||||||
videoStatekey: _key,
|
videoStatekey: _key,
|
||||||
bottomButtonBarWidget: _mobileBottomButtonBar(context),
|
bottomButtonBarWidget: _mobileBottomButtonBar(context),
|
||||||
streamController: _streamController,
|
streamController: _streamController,
|
||||||
|
doubleSpeed: (value) {
|
||||||
|
_isDoubleSpeed.value = value ?? false;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
width: context.width(1),
|
width: context.width(1),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
class DesktopControllerWidget extends StatefulWidget {
|
class DesktopControllerWidget extends StatefulWidget {
|
||||||
final Function(Duration?) tempDuration;
|
final Function(Duration?) tempDuration;
|
||||||
|
final Function(bool?) doubleSpeed;
|
||||||
final AnimeStreamController streamController;
|
final AnimeStreamController streamController;
|
||||||
final VideoController videoController;
|
final VideoController videoController;
|
||||||
final Widget topButtonBarWidget;
|
final Widget topButtonBarWidget;
|
||||||
|
|
@ -29,7 +30,8 @@ class DesktopControllerWidget extends StatefulWidget {
|
||||||
required this.streamController,
|
required this.streamController,
|
||||||
required this.videoStatekey,
|
required this.videoStatekey,
|
||||||
required this.seekToWidget,
|
required this.seekToWidget,
|
||||||
required this.tempDuration});
|
required this.tempDuration,
|
||||||
|
required this.doubleSpeed});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DesktopControllerWidget> createState() =>
|
State<DesktopControllerWidget> createState() =>
|
||||||
|
|
@ -46,6 +48,7 @@ class _DesktopControllerWidgetState extends State<DesktopControllerWidget> {
|
||||||
|
|
||||||
int swipeDuration = 0; // Duration to seek in video
|
int swipeDuration = 0; // Duration to seek in video
|
||||||
bool showSwipeDuration = false; // Whether to show the seek duration overlay
|
bool showSwipeDuration = false; // Whether to show the seek duration overlay
|
||||||
|
double previousPlaybackSpeed = -1;
|
||||||
|
|
||||||
late bool buffering = widget.videoController.player.state.buffering;
|
late bool buffering = widget.videoController.player.state.buffering;
|
||||||
final controlsHoverDuration = const Duration(seconds: 3);
|
final controlsHoverDuration = const Duration(seconds: 3);
|
||||||
|
|
@ -230,6 +233,21 @@ class _DesktopControllerWidgetState extends State<DesktopControllerWidget> {
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
|
onLongPressStart: (e) {
|
||||||
|
previousPlaybackSpeed =
|
||||||
|
widget.videoController.player.state.rate;
|
||||||
|
widget.videoController.player
|
||||||
|
.setRate(previousPlaybackSpeed * 2);
|
||||||
|
widget.doubleSpeed(true);
|
||||||
|
},
|
||||||
|
onLongPressEnd: (e) {
|
||||||
|
if (previousPlaybackSpeed != -1) {
|
||||||
|
widget.videoController.player
|
||||||
|
.setRate(previousPlaybackSpeed);
|
||||||
|
previousPlaybackSpeed = -1;
|
||||||
|
widget.doubleSpeed(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
onTapUp: !toggleFullscreenOnDoublePress
|
onTapUp: !toggleFullscreenOnDoublePress
|
||||||
? null
|
? null
|
||||||
: (e) {
|
: (e) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import 'package:media_kit_video/media_kit_video.dart';
|
||||||
import 'package:media_kit_video/media_kit_video_controls/src/controls/extensions/duration.dart';
|
import 'package:media_kit_video/media_kit_video_controls/src/controls/extensions/duration.dart';
|
||||||
|
|
||||||
class MobileControllerWidget extends ConsumerStatefulWidget {
|
class MobileControllerWidget extends ConsumerStatefulWidget {
|
||||||
|
final Function(bool?) doubleSpeed;
|
||||||
final AnimeStreamController streamController;
|
final AnimeStreamController streamController;
|
||||||
final VideoController videoController;
|
final VideoController videoController;
|
||||||
final Widget topButtonBarWidget;
|
final Widget topButtonBarWidget;
|
||||||
|
|
@ -28,7 +29,8 @@ class MobileControllerWidget extends ConsumerStatefulWidget {
|
||||||
required this.topButtonBarWidget,
|
required this.topButtonBarWidget,
|
||||||
required this.bottomButtonBarWidget,
|
required this.bottomButtonBarWidget,
|
||||||
required this.streamController,
|
required this.streamController,
|
||||||
required this.videoStatekey});
|
required this.videoStatekey,
|
||||||
|
required this.doubleSpeed});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<MobileControllerWidget> createState() =>
|
ConsumerState<MobileControllerWidget> createState() =>
|
||||||
|
|
@ -58,6 +60,7 @@ class _MobileControllerWidgetState
|
||||||
Offset.zero; // Initial position for horizontal drag
|
Offset.zero; // Initial position for horizontal drag
|
||||||
int swipeDuration = 0; // Duration to seek in video
|
int swipeDuration = 0; // Duration to seek in video
|
||||||
bool showSwipeDuration = false; // Whether to show the seek duration overlay
|
bool showSwipeDuration = false; // Whether to show the seek duration overlay
|
||||||
|
double previousPlaybackSpeed = -1;
|
||||||
|
|
||||||
late bool buffering = widget.videoController.player.state.buffering;
|
late bool buffering = widget.videoController.player.state.buffering;
|
||||||
final controlsHoverDuration = const Duration(seconds: 3);
|
final controlsHoverDuration = const Duration(seconds: 3);
|
||||||
|
|
@ -346,6 +349,21 @@ class _MobileControllerWidgetState
|
||||||
onDoubleTapSeekBackward();
|
onDoubleTapSeekBackward();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLongPressStart: (e) {
|
||||||
|
previousPlaybackSpeed =
|
||||||
|
widget.videoController.player.state.rate;
|
||||||
|
widget.videoController.player
|
||||||
|
.setRate(previousPlaybackSpeed * 2);
|
||||||
|
widget.doubleSpeed(true);
|
||||||
|
},
|
||||||
|
onLongPressEnd: (e) {
|
||||||
|
if (previousPlaybackSpeed != -1) {
|
||||||
|
widget.videoController.player
|
||||||
|
.setRate(previousPlaybackSpeed);
|
||||||
|
previousPlaybackSpeed = -1;
|
||||||
|
widget.doubleSpeed(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
onHorizontalDragUpdate: (details) {
|
onHorizontalDragUpdate: (details) {
|
||||||
onHorizontalDragUpdate(details);
|
onHorizontalDragUpdate(details);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ part of 'aniskip.dart';
|
||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$aniSkipHash() => r'887869b54e2e151633efd46da83bde845e14f421';
|
String _$aniSkipHash() => r'2e5d19b025a2207ff64da7bf7908450ea9e5ff8c';
|
||||||
|
|
||||||
/// See also [AniSkip].
|
/// See also [AniSkip].
|
||||||
@ProviderFor(AniSkip)
|
@ProviderFor(AniSkip)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ part of 'anilist.dart';
|
||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$anilistHash() => r'70e8cd537270a9054a1ef72de117fc7ad5545218';
|
String _$anilistHash() => r'ddd07acc8d28d2aa95c942566109e9393ca9e5ed';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue