@@ -104,7 +104,9 @@ class MediaPlayerState extends State<MediaPlayer>
104
104
void _initializePlayer () {
105
105
currentQuality = widget.videos[widget.index];
106
106
videoPlayerController = WindowsPlayer (resizeMode, settings);
107
- var sourceName = context.currentService (listen: false ).getName;
107
+ var sourceName = context
108
+ .currentService (listen: false )
109
+ .getName;
108
110
var currentProgress = loadCustomData <int >(
109
111
"${widget .media .id }-${widget .currentEpisode .number }-$sourceName -current" ,
110
112
);
@@ -114,7 +116,9 @@ class MediaPlayerState extends State<MediaPlayer>
114
116
}
115
117
116
118
void _loadPlayerSettings () {
117
- settings = loadCustomData ('${widget .media .id }-${context .currentService (listen : false ).getName }-PlayerSettings' ) ?? loadData (PrefName .playerSettings);
119
+ settings = loadCustomData ('${widget .media .id }-${context
120
+ .currentService (listen : false )
121
+ .getName }-PlayerSettings' ) ?? loadData (PrefName .playerSettings);
118
122
widget.media.anime? .playerSettings = settings;
119
123
resizeMode = (resizeMap[settings.resizeMode] ?? BoxFit .contain).obs;
120
124
viewType = loadSelected (widget.media).recyclerStyle.obs;
@@ -170,7 +174,7 @@ class MediaPlayerState extends State<MediaPlayer>
170
174
crossAxisAlignment: CrossAxisAlignment .start,
171
175
children: [
172
176
Obx (
173
- () {
177
+ () {
174
178
return MouseRegion (
175
179
onHover: (_) => _onMouseMoved (),
176
180
cursor: showControls.value
@@ -182,14 +186,15 @@ class MediaPlayerState extends State<MediaPlayer>
182
186
},
183
187
),
184
188
Obx (
185
- () {
189
+ () {
186
190
if (! showEpisodes.value) {
187
191
return const SizedBox ();
188
192
}
189
193
return GestureDetector (
190
194
onHorizontalDragUpdate: (details) {
191
195
setState (
192
- () => episodePanelWidth =
196
+ () =>
197
+ episodePanelWidth =
193
198
(episodePanelWidth! - details.delta.dx)
194
199
.clamp (minWidth, availableWidth),
195
200
);
@@ -225,34 +230,31 @@ class MediaPlayerState extends State<MediaPlayer>
225
230
children: [
226
231
videoPlayerController.playerWidget (),
227
232
_buildSubtitle (),
228
- AnimatedAlign (
229
- alignment: Alignment .topCenter,
230
- duration: const Duration (milliseconds: 300 ),
231
- child: Card (
232
- color: Colors .black.withOpacity (0.5 ),
233
- shape: RoundedRectangleBorder (
234
- borderRadius: BorderRadius .circular (16 ),
235
- ),
236
- child: Padding (
237
- padding: const EdgeInsets .symmetric (
238
- horizontal: 8.0 ,
239
- vertical: 4.0 ,
233
+ if (isLongPress.value)
234
+ AnimatedAlign (
235
+ alignment: Alignment .topCenter,
236
+ duration: const Duration (milliseconds: 300 ),
237
+ child: Card (
238
+ color: Colors .black.withOpacity (0.5 ),
239
+ shape: RoundedRectangleBorder (
240
+ borderRadius: BorderRadius .circular (16 ),
240
241
),
241
- child: Obx (
242
- () {
243
- return isLongPress.value ? Text (
244
- '${videoPlayerController .currentSpeed .value }x ' ,
245
- style: const TextStyle (
246
- color: Colors .white,
247
- fontSize: 16 ,
248
- fontWeight: FontWeight .bold,
249
- ),
250
- ) : SizedBox ();
251
- },
242
+ child: Padding (
243
+ padding: const EdgeInsets .symmetric (
244
+ horizontal: 8.0 ,
245
+ vertical: 4.0 ,
246
+ ),
247
+ child: Text (
248
+ '${videoPlayerController .currentSpeed .value }x ' ,
249
+ style: const TextStyle (
250
+ color: Colors .white,
251
+ fontSize: 16 ,
252
+ fontWeight: FontWeight .bold,
253
+ ),
254
+ ),
252
255
),
253
256
),
254
257
),
255
- ),
256
258
KeyboardListener (
257
259
focusNode: focusNode,
258
260
onKeyEvent: _handleKeyPress,
@@ -267,7 +269,10 @@ class MediaPlayerState extends State<MediaPlayer>
267
269
onVerticalDragUpdate: (e) async {
268
270
final delta = e.delta.dy;
269
271
final Offset position = e.localPosition;
270
- if (position.dx <= MediaQuery .of (context).size.width / 2 ) {
272
+ if (position.dx <= MediaQuery
273
+ .of (context)
274
+ .size
275
+ .width / 2 ) {
271
276
final brightness = _brightnessValue.value - delta / 500 ;
272
277
final result = brightness.clamp (0.0 , 1.0 );
273
278
setBrightness (result);
@@ -315,59 +320,62 @@ class MediaPlayerState extends State<MediaPlayer>
315
320
return const SizedBox ();
316
321
}
317
322
return Obx (
318
- () => AnimatedPositioned (
319
- right: 0 ,
320
- left: 0 ,
321
- top: 0 ,
322
- duration: const Duration (milliseconds: 100 ),
323
- bottom: showControls.value
324
- ? 100
325
- : (24 + settings.subtitleBottomPadding.toDouble ()),
326
- child: AnimatedContainer (
327
- alignment: Alignment .bottomCenter,
328
- duration: const Duration (milliseconds: 300 ),
329
- child: Column (
330
- mainAxisSize: MainAxisSize .min,
331
- crossAxisAlignment: CrossAxisAlignment .center,
332
- mainAxisAlignment: MainAxisAlignment .center,
333
- children: [
334
- Container (
335
- padding:
323
+ () =>
324
+ AnimatedPositioned (
325
+ right: 0 ,
326
+ left: 0 ,
327
+ top: 0 ,
328
+ duration: const Duration (milliseconds: 100 ),
329
+ bottom: showControls.value
330
+ ? 100
331
+ : (24 + settings.subtitleBottomPadding.toDouble ()),
332
+ child: AnimatedContainer (
333
+ alignment: Alignment .bottomCenter,
334
+ duration: const Duration (milliseconds: 300 ),
335
+ child: Column (
336
+ mainAxisSize: MainAxisSize .min,
337
+ crossAxisAlignment: CrossAxisAlignment .center,
338
+ mainAxisAlignment: MainAxisAlignment .center,
339
+ children: [
340
+ Container (
341
+ padding:
336
342
const EdgeInsets .symmetric (horizontal: 10 , vertical: 5 ),
337
- decoration: BoxDecoration (
338
- color: videoPlayerController.subtitle[0 ].isEmpty
339
- ? Colors .transparent
340
- : Color (
341
- settings.subtitleBackgroundColor,
342
- ),
343
- borderRadius: BorderRadius .circular (12 ),
344
- ),
345
- child: Text (
346
- [
347
- for (final line in videoPlayerController.subtitle)
348
- if (line.trim ().isNotEmpty) line.trim (),
349
- ].join ('\n ' ),
350
- textAlign: TextAlign .center,
351
- style: TextStyle (
352
- fontSize: settings.subtitleSize.toDouble (),
353
- fontWeight:
343
+ decoration: BoxDecoration (
344
+ color: videoPlayerController.subtitle[0 ].isEmpty
345
+ ? Colors .transparent
346
+ : Color (
347
+ settings.subtitleBackgroundColor,
348
+ ),
349
+ borderRadius: BorderRadius .circular (12 ),
350
+ ),
351
+ child: Text (
352
+ [
353
+ for (final line in videoPlayerController.subtitle)
354
+ if (line
355
+ .trim ()
356
+ .isNotEmpty) line.trim (),
357
+ ].join ('\n ' ),
358
+ textAlign: TextAlign .center,
359
+ style: TextStyle (
360
+ fontSize: settings.subtitleSize.toDouble (),
361
+ fontWeight:
354
362
FontWeight .values[settings.subtitleWeight.toInt ()],
355
- fontFamily: settings.subtitleFont,
356
- color: Color (settings.subtitleColor),
357
- shadows: [
358
- Shadow (
359
- offset: const Offset (1.0 , 1.0 ),
360
- blurRadius: 10.0 ,
361
- color: Color (settings.subtitleOutlineColor),
363
+ fontFamily: settings.subtitleFont,
364
+ color: Color (settings.subtitleColor),
365
+ shadows: [
366
+ Shadow (
367
+ offset: const Offset (1.0 , 1.0 ),
368
+ blurRadius: 10.0 ,
369
+ color: Color (settings.subtitleOutlineColor),
370
+ ),
371
+ ],
362
372
),
363
- ] ,
373
+ ) ,
364
374
),
365
- ) ,
375
+ ] ,
366
376
),
367
- ] ,
377
+ ) ,
368
378
),
369
- ),
370
- ),
371
379
);
372
380
}
373
381
@@ -450,7 +458,10 @@ class MediaPlayerState extends State<MediaPlayer>
450
458
final skipDuration = 0. obs;
451
459
452
460
void _handleDoubleTap (TapDownDetails details) {
453
- final screenWidth = MediaQuery .of (context).size.width;
461
+ final screenWidth = MediaQuery
462
+ .of (context)
463
+ .size
464
+ .width;
454
465
final tapPosition = details.globalPosition;
455
466
final isLeft = tapPosition.dx < screenWidth / 2 ;
456
467
_skipSegments (isLeft);
@@ -460,6 +471,7 @@ class MediaPlayerState extends State<MediaPlayer>
460
471
double currentSpeed = 2.0 ;
461
472
Offset ? longPressStartPosition;
462
473
RxBool isLongPress = false .obs;
474
+
463
475
void _handleLongPressStart (LongPressStartDetails details) {
464
476
isLongPress.value = true ;
465
477
initialSpeed = videoPlayerController.currentSpeed.value;
@@ -525,8 +537,14 @@ class MediaPlayerState extends State<MediaPlayer>
525
537
return const SizedBox ();
526
538
}
527
539
return AnimatedPositioned (
528
- left: isLeftSide.value ? 0 : MediaQuery .of (context).size.width / 1.5 ,
529
- width: MediaQuery .of (context).size.width / 2.5 ,
540
+ left: isLeftSide.value ? 0 : MediaQuery
541
+ .of (context)
542
+ .size
543
+ .width / 1.5 ,
544
+ width: MediaQuery
545
+ .of (context)
546
+ .size
547
+ .width / 2.5 ,
530
548
top: 0 ,
531
549
bottom: 0 ,
532
550
duration: const Duration (milliseconds: 1000 ),
@@ -603,11 +621,11 @@ class MediaPlayerState extends State<MediaPlayer>
603
621
Widget _buildEpisodeList () {
604
622
var episodeList = widget.media.anime? .episodes ?? {};
605
623
var (chunk, initChunkIndex) =
606
- buildChunks (context, episodeList, widget.media.userProgress.toString ());
624
+ buildChunks (context, episodeList, widget.media.userProgress.toString ());
607
625
608
626
RxInt selectedChunkIndex = (- 1 ).obs;
609
627
selectedChunkIndex =
610
- selectedChunkIndex.value == - 1 ? initChunkIndex : selectedChunkIndex;
628
+ selectedChunkIndex.value == - 1 ? initChunkIndex : selectedChunkIndex;
611
629
612
630
return ScrollConfig (
613
631
context,
@@ -624,7 +642,7 @@ class MediaPlayerState extends State<MediaPlayer>
624
642
reverse,
625
643
),
626
644
Obx (
627
- () {
645
+ () {
628
646
var reversed = reverse.value
629
647
? chunk.map ((element) => element.reversed.toList ()).toList ()
630
648
: chunk;
@@ -662,19 +680,23 @@ class MediaPlayerState extends State<MediaPlayer>
662
680
onPressed: () => settingsDialog (),
663
681
icon: Icon (
664
682
Icons .menu_rounded,
665
- color: Theme .of (context).colorScheme.onSurface,
683
+ color: Theme
684
+ .of (context)
685
+ .colorScheme
686
+ .onSurface,
666
687
),
667
688
),
668
689
],
669
690
),
670
691
);
671
692
}
672
693
673
- void settingsDialog () => AnimeCompactSettings (
694
+ void settingsDialog () =>
695
+ AnimeCompactSettings (
674
696
context,
675
697
widget.media,
676
698
widget.source,
677
- (i) {
699
+ (i) {
678
700
viewType.value = i.recyclerStyle;
679
701
reverse.value = i.recyclerReversed;
680
702
},
@@ -694,7 +716,7 @@ class MediaPlayerState extends State<MediaPlayer>
694
716
var keyNumber = int .parse (event.logicalKey.keyLabel);
695
717
696
718
var videoDurationSeconds =
697
- _timeStringToSeconds (videoPlayerController.maxTime.value);
719
+ _timeStringToSeconds (videoPlayerController.maxTime.value);
698
720
var targetSeconds = (keyNumber / 10 ) * videoDurationSeconds;
699
721
700
722
if (keyNumber == 1 ) {
@@ -728,15 +750,17 @@ class MediaPlayerState extends State<MediaPlayer>
728
750
729
751
void saveSelected (int id, Selected data) {
730
752
var sourceName =
731
- Provider .of <MediaServiceProvider >(Get .context! , listen: false )
753
+ Provider
754
+ .of <MediaServiceProvider >(Get .context! , listen: false )
732
755
.currentService
733
756
.getName;
734
757
saveCustomData ("Selected-$id -$sourceName " , data);
735
758
}
736
759
737
760
Selected loadSelected (m.Media mediaData) {
738
761
var sourceName =
739
- Provider .of <MediaServiceProvider >(Get .context! , listen: false )
762
+ Provider
763
+ .of <MediaServiceProvider >(Get .context! , listen: false )
740
764
.currentService
741
765
.getName;
742
766
return loadCustomData ("Selected-${mediaData .id }-$sourceName " ) ?? Selected ();
0 commit comments