-
Notifications
You must be signed in to change notification settings - Fork 136
Prepare fullscreen support #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,30 @@ import 'package:dart_vlc_ffi/src/device.dart'; | |
import 'package:dart_vlc_ffi/src/player.dart'; | ||
import 'package:dart_vlc_ffi/src/playerState/playerState.dart'; | ||
|
||
class FullscreenState { | ||
final bool isFullscreen; | ||
final bool isFullscreenAllowed; | ||
const FullscreenState( | ||
{required this.isFullscreen, required this.isFullscreenAllowed}); | ||
|
||
FullscreenState copyWith({bool? isFullscreen, bool? isFullscreenAllowed}) => | ||
FullscreenState( | ||
isFullscreen: isFullscreen ?? this.isFullscreen, | ||
isFullscreenAllowed: isFullscreenAllowed ?? this.isFullscreenAllowed); | ||
} | ||
|
||
abstract class FullscreenController extends ValueNotifier<FullscreenState> { | ||
FullscreenController() | ||
: super(FullscreenState(isFullscreenAllowed: true, isFullscreen: false)); | ||
|
||
bool get isFullscreen => value.isFullscreen; | ||
void toggleFullscreen(); | ||
} | ||
|
||
class Control extends StatefulWidget { | ||
final Widget child; | ||
final Player player; | ||
final FullscreenController? fullscreenController; | ||
final bool? showTimeLeft; | ||
final double? progressBarThumbRadius; | ||
final double? progressBarThumbGlowRadius; | ||
|
@@ -25,6 +46,7 @@ class Control extends StatefulWidget { | |
Control({ | ||
required this.child, | ||
required this.player, | ||
this.fullscreenController, | ||
required this.showTimeLeft, | ||
required this.progressBarThumbRadius, | ||
required this.progressBarThumbGlowRadius, | ||
|
@@ -124,6 +146,34 @@ class ControlState extends State<Control> with SingleTickerProviderStateMixin { | |
), | ||
), | ||
), | ||
if (widget.fullscreenController != null) | ||
Positioned( | ||
left: 16, | ||
bottom: 10, | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.end, | ||
children: [ | ||
ValueListenableBuilder<FullscreenState>( | ||
valueListenable: widget.fullscreenController!, | ||
builder: (context, state, _) => IconButton( | ||
color: Colors.white, | ||
disabledColor: Colors.white, | ||
iconSize: 30, | ||
icon: Icon( | ||
state.isFullscreen | ||
? Icons.fullscreen_exit | ||
: Icons.fullscreen, | ||
), | ||
onPressed: state.isFullscreenAllowed | ||
? () { | ||
widget.fullscreenController | ||
?.toggleFullscreen(); | ||
} | ||
: null, | ||
)), | ||
], | ||
), | ||
), | ||
Positioned( | ||
left: 0, | ||
right: 0, | ||
|
@@ -247,8 +297,8 @@ class ControlState extends State<Control> with SingleTickerProviderStateMixin { | |
), | ||
), | ||
Positioned( | ||
right: 15, | ||
bottom: 12.5, | ||
right: 16, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we don't keep old position? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding an additional button certainly needs more space, infact this UI code wasn't written by me but a contributor. Ideally, one would write their own custom designed video controls. These "just work" and are very "generic" & here to show the plugin capabilities etc. in the example itself. |
||
bottom: 10, | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.end, | ||
children: [ | ||
|
@@ -260,7 +310,7 @@ class ControlState extends State<Control> with SingleTickerProviderStateMixin { | |
backgroundColor: widget.volumeBackgroundColor, | ||
), | ||
PopupMenuButton( | ||
iconSize: 24, | ||
iconSize: 28, | ||
icon: Icon(Icons.speaker, color: Colors.white), | ||
onSelected: (Device device) { | ||
player.setDevice(device); | ||
|
@@ -361,7 +411,6 @@ class _VolumeControlState extends State<VolumeControl> { | |
setState(() => _showVolume = false); | ||
}, | ||
child: Container( | ||
width: 60, | ||
height: 250, | ||
child: Card( | ||
color: widget.backgroundColor, | ||
|
@@ -400,6 +449,7 @@ class _VolumeControlState extends State<VolumeControl> { | |
}, | ||
child: IconButton( | ||
color: Colors.white, | ||
iconSize: 28, | ||
onPressed: () => muteUnmute(), | ||
icon: Icon(getIcon()), | ||
), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ class VideoFrame { | |
final int videoHeight; | ||
final Uint8List byteArray; | ||
|
||
VideoFrame({ | ||
const VideoFrame({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should have separately a refactor pull request. Mix refactors and fullscreen feature makes difficult to track the codes |
||
required this.playerId, | ||
required this.videoWidth, | ||
required this.videoHeight, | ||
|
@@ -87,43 +87,46 @@ class Video extends StatefulWidget { | |
// Built-In video controls. | ||
final bool showControls; | ||
|
||
// Radius of the progressbar's thumb | ||
/// Radius of the progressbar's thumb | ||
final double? progressBarThumbRadius; | ||
|
||
// Radius of the progressbar's glow of the thumb | ||
/// Radius of the progressbar's glow of the thumb | ||
final double? progressBarThumbGlowRadius; | ||
|
||
// Active color of the progress bar | ||
/// Active color of the progress bar | ||
final Color? progressBarActiveColor; | ||
|
||
// Inactive color of the progress bar | ||
/// Inactive color of the progress bar | ||
final Color? progressBarInactiveColor; | ||
|
||
// Thumb color of the progress bar | ||
/// Thumb color of the progress bar | ||
final Color? progressBarThumbColor; | ||
|
||
// Thumb's glow color of the progress bar | ||
final Color? progressBarThumbGlowColor; | ||
|
||
// TextStyle for the Progress Bar | ||
/// TextStyle for the Progress Bar | ||
final TextStyle progressBarTextStyle; | ||
|
||
// Active color of the volume slider | ||
/// Active color of the volume slider | ||
final Color? volumeActiveColor; | ||
|
||
// Inactive color of the volume slider | ||
/// Inactive color of the volume slider | ||
final Color? volumeInactiveColor; | ||
|
||
// Background color of the volume slider | ||
/// Background color of the volume slider | ||
final Color volumeBackgroundColor; | ||
|
||
// Thumb color of the volume slider | ||
/// Thumb color of the volume slider | ||
final Color? volumeThumbColor; | ||
|
||
// if you want the progress bar to display the time left while playing | ||
// instead of the total time, set this to true | ||
/// if you want the progress bar to display the time left while playing | ||
/// instead of the total time, set this to true | ||
final bool showTimeLeft; | ||
|
||
/// An optional [FullscreenController]. | ||
final FullscreenController? fullscreenController; | ||
|
||
Video({ | ||
@Deprecated('playerId is deprecated. Use player instead.') int? playerId, | ||
Player? player, | ||
|
@@ -146,6 +149,7 @@ class Video extends StatefulWidget { | |
this.showTimeLeft = false, | ||
this.progressBarTextStyle = const TextStyle(), | ||
this.filterQuality = FilterQuality.low, | ||
this.fullscreenController, | ||
Key? key, | ||
}) : player = player ?? players[playerId]! as Player, | ||
super(key: key); | ||
|
@@ -175,6 +179,7 @@ abstract class _VideoStateBase extends State<Video> { | |
? Control( | ||
key: controlKey, | ||
player: widget.player, | ||
fullscreenController: widget.fullscreenController, | ||
progressBarThumbRadius: widget.progressBarThumbRadius, | ||
progressBarThumbGlowRadius: widget.progressBarThumbGlowRadius, | ||
progressBarActiveColor: widget.progressBarActiveColor, | ||
|
@@ -209,7 +214,6 @@ class _VideoStateTexture extends _VideoStateBase { | |
}); | ||
}); | ||
super.initState(); | ||
if (mounted) setState(() {}); | ||
} | ||
|
||
Widget present() { | ||
|
@@ -283,7 +287,6 @@ class _VideoStateFallback extends _VideoStateBase { | |
if (mounted) setState(() {}); | ||
}); | ||
super.initState(); | ||
if (mounted) setState(() {}); | ||
} | ||
|
||
Widget present() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that you import controls without using it. All codes below are just for refactor purpose.