-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add buffer bar, theme video player (#715)
* Add buffer bar, theme video player * Reuse controls * Improve video controls
- Loading branch information
1 parent
5f42896
commit 8ce1402
Showing
14 changed files
with
271 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:media_kit_video/media_kit_video.dart'; | ||
import 'package:yaru/constants.dart'; | ||
|
||
import '../../../common.dart'; | ||
import '../../../get.dart'; | ||
import '../../../l10n.dart'; | ||
import '../player_model.dart'; | ||
import 'full_height_player_top_controls.dart'; | ||
import 'player_main_controls.dart'; | ||
import 'player_view.dart'; | ||
|
||
class FullHeightVideoPlayer extends StatelessWidget with WatchItMixin { | ||
const FullHeightVideoPlayer({super.key, required this.playerViewMode}); | ||
|
||
final PlayerViewMode playerViewMode; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
const baseColor = Colors.white; | ||
|
||
final audio = watchPropertyValue((PlayerModel m) => m.audio); | ||
final playerModel = getIt<PlayerModel>(); | ||
final isOnline = watchPropertyValue((PlayerModel m) => m.isOnline); | ||
final active = audio?.path != null || isOnline; | ||
|
||
final controls = FullHeightPlayerTopControls( | ||
iconColor: baseColor, | ||
playerViewMode: playerViewMode, | ||
padding: EdgeInsets.zero, | ||
); | ||
|
||
final mediaKitTheme = MaterialVideoControlsThemeData( | ||
seekBarThumbColor: baseColor, | ||
seekBarColor: baseColor.withOpacity(0.3), | ||
seekBarPositionColor: baseColor.withOpacity(0.9), | ||
seekBarBufferColor: baseColor.withOpacity(0.6), | ||
buttonBarButtonColor: baseColor, | ||
controlsHoverDuration: const Duration(seconds: 10), | ||
primaryButtonBar: [ | ||
SizedBox( | ||
width: 300, | ||
child: PlayerMainControls( | ||
active: active, | ||
playPrevious: playerModel.playNext, | ||
playNext: playerModel.playNext, | ||
iconColor: baseColor, | ||
avatarColor: baseColor.withOpacity(0.1), | ||
), | ||
), | ||
], | ||
seekBarMargin: const EdgeInsets.all(kYaruPagePadding), | ||
topButtonBarMargin: const EdgeInsets.only(right: kYaruPagePadding), | ||
topButtonBar: [ | ||
const Spacer(), | ||
controls, | ||
Tooltip( | ||
message: context.l10n.leaveFullScreen, | ||
child: MaterialFullscreenButton( | ||
icon: Icon( | ||
Iconz().fullScreenExit, | ||
color: baseColor, | ||
), | ||
), | ||
), | ||
], | ||
bottomButtonBar: [], | ||
padding: const EdgeInsets.all(20), | ||
); | ||
|
||
return MaterialVideoControlsTheme( | ||
key: ValueKey(audio?.url), | ||
fullscreen: mediaKitTheme, | ||
normal: mediaKitTheme.copyWith( | ||
topButtonBar: [ | ||
const Spacer(), | ||
controls, | ||
Tooltip( | ||
message: context.l10n.fullScreen, | ||
child: MaterialFullscreenButton( | ||
icon: Icon( | ||
Iconz().fullScreen, | ||
color: baseColor, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
child: RepaintBoundary( | ||
child: Video( | ||
controller: getIt<PlayerModel>().controller, | ||
controls: (state) => MaterialVideoControls(state), | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.