@@ -5,7 +5,6 @@ import 'dart:math';
5
5
import 'package:dantotsu/Preferences/HiveDataClasses/DefaultPlayerSettings/DefaultPlayerSettings.dart' ;
6
6
import 'package:dantotsu/Preferences/PrefManager.dart' ;
7
7
import 'package:dantotsu/Preferences/Preferences.dart' ;
8
- import 'package:flutter/foundation.dart' ;
9
8
import 'package:flutter/material.dart' ;
10
9
import 'package:flutter/services.dart' ;
11
10
import 'package:get/get.dart' ;
@@ -92,16 +91,14 @@ class MediaPlayerState extends State<MediaPlayer>
92
91
}
93
92
}
94
93
95
- final _isCursorVisible = true .obs;
96
94
Timer ? _hideCursorTimer;
95
+
97
96
void _onMouseMoved () {
98
- if (! _isCursorVisible.value) {
99
- _isCursorVisible.value = true ;
97
+ if (! showControls.value) {
100
98
showControls.value = true ;
101
99
}
102
100
_hideCursorTimer? .cancel ();
103
101
_hideCursorTimer = Timer (const Duration (seconds: 3 ), () {
104
- _isCursorVisible.value = false ;
105
102
showControls.value = false ;
106
103
});
107
104
}
@@ -110,6 +107,7 @@ class MediaPlayerState extends State<MediaPlayer>
110
107
currentQuality = widget.videos[widget.index];
111
108
videoPlayerController = WindowsPlayer (resizeMode, settings);
112
109
videoPlayerController.open (currentQuality.url, Duration .zero);
110
+ _onMouseMoved ();
113
111
}
114
112
115
113
void _loadPlayerSettings () {
@@ -161,39 +159,35 @@ class MediaPlayerState extends State<MediaPlayer>
161
159
Widget build (BuildContext context) {
162
160
return Obx (
163
161
() {
164
- return GestureDetector (
165
- onTap: _onMouseMoved,
166
- onPanUpdate: (_) => _onMouseMoved (),
167
- child: MouseRegion (
168
- onHover: (_) => _onMouseMoved (),
169
- cursor: defaultTargetPlatform == TargetPlatform .macOS || defaultTargetPlatform == TargetPlatform .windows
170
- ? (_isCursorVisible.value
171
- ? SystemMouseCursors .basic
172
- : SystemMouseCursors .none)
173
- : SystemMouseCursors .basic,
174
- child: Scaffold (
175
- body: LayoutBuilder (
176
- builder: (context, constraints) {
177
- const double minWidth = 250 ;
178
- final double availableWidth = constraints.maxWidth;
179
-
180
- double episodePanelWidth =
181
- (availableWidth / 3 ).clamp (minWidth, availableWidth);
182
-
183
- return StatefulBuilder (
184
- builder: (context, setState) {
185
- return Row (
186
- crossAxisAlignment: CrossAxisAlignment .start,
187
- children: [
188
- _buildVideoPlayer (availableWidth, episodePanelWidth),
189
- Obx (() {
162
+ return MouseRegion (
163
+ onHover: (_) => _onMouseMoved (),
164
+ cursor: showControls.value
165
+ ? SystemMouseCursors .basic
166
+ : SystemMouseCursors .none,
167
+ child: Scaffold (
168
+ body: LayoutBuilder (
169
+ builder: (context, constraints) {
170
+ const double minWidth = 250 ;
171
+ final double availableWidth = constraints.maxWidth;
172
+
173
+ double episodePanelWidth =
174
+ (availableWidth / 3 ).clamp (minWidth, availableWidth);
175
+
176
+ return StatefulBuilder (
177
+ builder: (context, setState) {
178
+ return Row (
179
+ crossAxisAlignment: CrossAxisAlignment .start,
180
+ children: [
181
+ _buildVideoPlayer (availableWidth, episodePanelWidth),
182
+ Obx (
183
+ () {
190
184
if (! showEpisodes.value) {
191
185
return const SizedBox ();
192
186
}
193
187
return GestureDetector (
194
188
onHorizontalDragUpdate: (details) {
195
189
setState (
196
- () => episodePanelWidth =
190
+ () => episodePanelWidth =
197
191
(episodePanelWidth - details.delta.dx)
198
192
.clamp (minWidth, availableWidth),
199
193
);
@@ -206,13 +200,13 @@ class MediaPlayerState extends State<MediaPlayer>
206
200
),
207
201
),
208
202
);
209
- }) ,
210
- ] ,
211
- );
212
- },
213
- );
214
- },
215
- ) ,
203
+ },
204
+ ) ,
205
+ ],
206
+ );
207
+ },
208
+ );
209
+ } ,
216
210
),
217
211
),
218
212
);
@@ -235,12 +229,12 @@ class MediaPlayerState extends State<MediaPlayer>
235
229
onKeyEvent: _handleKeyPress,
236
230
child: GestureDetector (
237
231
behavior: HitTestBehavior .opaque,
238
- onTapDown: (_) => showControls.value = ! showControls.value,
232
+ onTapDown: (_) => _onMouseMoved (),
233
+ onPanUpdate: (_) => _onMouseMoved (),
239
234
onDoubleTapDown: (t) => _handleDoubleTap (t),
240
235
onVerticalDragUpdate: (e) async {
241
236
final delta = e.delta.dy;
242
237
final Offset position = e.localPosition;
243
-
244
238
if (position.dx <= MediaQuery .of (context).size.width / 2 ) {
245
239
final brightness = _brightnessValue.value - delta / 500 ;
246
240
final result = brightness.clamp (0.0 , 1.0 );
0 commit comments