|
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';
|
@@ -385,13 +386,44 @@ class _MaterialControlsState extends State<MaterialControls>
|
385 | 386 | });
|
386 | 387 | }
|
387 | 388 | },
|
388 |
| - child: CenterPlayButton( |
389 |
| - backgroundColor: Colors.black54, |
390 |
| - iconColor: Colors.white, |
391 |
| - isFinished: isFinished, |
392 |
| - isPlaying: controller.value.isPlaying, |
393 |
| - show: showPlayButton, |
394 |
| - onPressed: _playPause, |
| 389 | + child: Container( |
| 390 | + alignment: Alignment.center, |
| 391 | + color: Colors |
| 392 | + .transparent, // The Gesture Detector doesn't expand to the full size of the container without this; Not sure why! |
| 393 | + child: Row( |
| 394 | + mainAxisAlignment: MainAxisAlignment.center, |
| 395 | + children: [ |
| 396 | + if (!isFinished && !chewieController.isLive) |
| 397 | + CenterSeekButton( |
| 398 | + iconData: Icons.replay_10, |
| 399 | + backgroundColor: Colors.black54, |
| 400 | + iconColor: Colors.white, |
| 401 | + show: showPlayButton, |
| 402 | + onPressed: _seekBackward, |
| 403 | + ), |
| 404 | + Container( |
| 405 | + margin: EdgeInsets.symmetric( |
| 406 | + horizontal: marginSize, |
| 407 | + ), |
| 408 | + child: CenterPlayButton( |
| 409 | + backgroundColor: Colors.black54, |
| 410 | + iconColor: Colors.white, |
| 411 | + isFinished: isFinished, |
| 412 | + isPlaying: controller.value.isPlaying, |
| 413 | + show: showPlayButton, |
| 414 | + onPressed: _playPause, |
| 415 | + ), |
| 416 | + ), |
| 417 | + if (!isFinished && !chewieController.isLive) |
| 418 | + CenterSeekButton( |
| 419 | + iconData: Icons.forward_10, |
| 420 | + backgroundColor: Colors.black54, |
| 421 | + iconColor: Colors.white, |
| 422 | + show: showPlayButton, |
| 423 | + onPressed: _seekForward, |
| 424 | + ), |
| 425 | + ], |
| 426 | + ), |
395 | 427 | ),
|
396 | 428 | );
|
397 | 429 | }
|
@@ -542,6 +574,36 @@ class _MaterialControlsState extends State<MaterialControls>
|
542 | 574 | });
|
543 | 575 | }
|
544 | 576 |
|
| 577 | + void _seekRelative(Duration relativeSeek) { |
| 578 | + _cancelAndRestartTimer(); |
| 579 | + final position = _latestValue.position + relativeSeek; |
| 580 | + final duration = _latestValue.duration; |
| 581 | + |
| 582 | + if (position < Duration.zero) { |
| 583 | + controller.seekTo(Duration.zero); |
| 584 | + } else if (position > duration) { |
| 585 | + controller.seekTo(duration); |
| 586 | + } else { |
| 587 | + controller.seekTo(position); |
| 588 | + } |
| 589 | + } |
| 590 | + |
| 591 | + void _seekBackward() { |
| 592 | + _seekRelative( |
| 593 | + const Duration( |
| 594 | + seconds: -10, |
| 595 | + ), |
| 596 | + ); |
| 597 | + } |
| 598 | + |
| 599 | + void _seekForward() { |
| 600 | + _seekRelative( |
| 601 | + const Duration( |
| 602 | + seconds: 10, |
| 603 | + ), |
| 604 | + ); |
| 605 | + } |
| 606 | + |
545 | 607 | void _startHideTimer() {
|
546 | 608 | final hideControlsTimer = chewieController.hideControlsTimer.isNegative
|
547 | 609 | ? ChewieController.defaultHideControlsTimer
|
|
0 commit comments