|
1 | 1 | import 'dart:async'; |
2 | 2 |
|
3 | 3 | import 'package:chewie/src/center_play_button.dart'; |
| 4 | +import 'package:chewie/src/center_seek_button.dart'; |
4 | 5 | import 'package:chewie/src/chewie_player.dart'; |
5 | 6 | import 'package:chewie/src/chewie_progress_colors.dart'; |
6 | 7 | import 'package:chewie/src/helpers/utils.dart'; |
@@ -388,13 +389,48 @@ class _MaterialControlsState extends State<MaterialControls> |
388 | 389 | }); |
389 | 390 | } |
390 | 391 | }, |
391 | | - child: CenterPlayButton( |
392 | | - backgroundColor: Colors.black54, |
393 | | - iconColor: Colors.white, |
394 | | - isFinished: isFinished, |
395 | | - isPlaying: controller.value.isPlaying, |
396 | | - show: showPlayButton, |
397 | | - onPressed: _playPause, |
| 392 | + child: Container( |
| 393 | + alignment: Alignment.center, |
| 394 | + color: Colors |
| 395 | + .transparent, // The Gesture Detector doesn't expand to the full size of the container without this; Not sure why! |
| 396 | + child: Row( |
| 397 | + mainAxisAlignment: MainAxisAlignment.center, |
| 398 | + children: [ |
| 399 | + if (!isFinished && !chewieController.isLive) |
| 400 | + CenterSeekButton( |
| 401 | + iconData: Icons.replay_10, |
| 402 | + backgroundColor: Colors.black54, |
| 403 | + iconColor: Colors.white, |
| 404 | + show: showPlayButton, |
| 405 | + fadeDuration: chewieController.materialSeekButtonFadeDuration, |
| 406 | + iconSize: chewieController.materialSeekButtonSize, |
| 407 | + onPressed: _seekBackward, |
| 408 | + ), |
| 409 | + Container( |
| 410 | + margin: EdgeInsets.symmetric( |
| 411 | + horizontal: marginSize, |
| 412 | + ), |
| 413 | + child: CenterPlayButton( |
| 414 | + backgroundColor: Colors.black54, |
| 415 | + iconColor: Colors.white, |
| 416 | + isFinished: isFinished, |
| 417 | + isPlaying: controller.value.isPlaying, |
| 418 | + show: showPlayButton, |
| 419 | + onPressed: _playPause, |
| 420 | + ), |
| 421 | + ), |
| 422 | + if (!isFinished && !chewieController.isLive) |
| 423 | + CenterSeekButton( |
| 424 | + iconData: Icons.forward_10, |
| 425 | + backgroundColor: Colors.black54, |
| 426 | + iconColor: Colors.white, |
| 427 | + show: showPlayButton, |
| 428 | + fadeDuration: chewieController.materialSeekButtonFadeDuration, |
| 429 | + iconSize: chewieController.materialSeekButtonSize, |
| 430 | + onPressed: _seekForward, |
| 431 | + ), |
| 432 | + ], |
| 433 | + ), |
398 | 434 | ), |
399 | 435 | ); |
400 | 436 | } |
@@ -546,6 +582,36 @@ class _MaterialControlsState extends State<MaterialControls> |
546 | 582 | }); |
547 | 583 | } |
548 | 584 |
|
| 585 | + void _seekRelative(Duration relativeSeek) { |
| 586 | + _cancelAndRestartTimer(); |
| 587 | + final position = _latestValue.position + relativeSeek; |
| 588 | + final duration = _latestValue.duration; |
| 589 | + |
| 590 | + if (position < Duration.zero) { |
| 591 | + controller.seekTo(Duration.zero); |
| 592 | + } else if (position > duration) { |
| 593 | + controller.seekTo(duration); |
| 594 | + } else { |
| 595 | + controller.seekTo(position); |
| 596 | + } |
| 597 | + } |
| 598 | + |
| 599 | + void _seekBackward() { |
| 600 | + _seekRelative( |
| 601 | + const Duration( |
| 602 | + seconds: -10, |
| 603 | + ), |
| 604 | + ); |
| 605 | + } |
| 606 | + |
| 607 | + void _seekForward() { |
| 608 | + _seekRelative( |
| 609 | + const Duration( |
| 610 | + seconds: 10, |
| 611 | + ), |
| 612 | + ); |
| 613 | + } |
| 614 | + |
549 | 615 | void _startHideTimer() { |
550 | 616 | final hideControlsTimer = chewieController.hideControlsTimer.isNegative |
551 | 617 | ? ChewieController.defaultHideControlsTimer |
@@ -618,6 +684,7 @@ class _MaterialControlsState extends State<MaterialControls> |
618 | 684 | Theme.of(context).colorScheme.surface.withOpacity(0.5), |
619 | 685 | backgroundColor: Theme.of(context).disabledColor.withOpacity(.5), |
620 | 686 | ), |
| 687 | + draggableProgressBar: chewieController.draggableProgressBar, |
621 | 688 | ), |
622 | 689 | ); |
623 | 690 | } |
|
0 commit comments