Skip to content
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

Some gesture added #1292

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Advanced video player based on video_player and Chewie. It's solves many typical
## Introduction
This plugin is based on [Chewie](https://github.com/brianegan/chewie). Chewie is awesome plugin and works well in many cases. Better Player is a continuation of ideas introduced in Chewie. Better player fix common bugs, adds more configuration options and solves typical use cases.

**Features:**
**Features:**

✔️ Fixed common bugs
✔️ Added advanced configuration options
✔️ Refactored player controls
Expand All @@ -86,7 +87,9 @@ This plugin is based on [Chewie](https://github.com/brianegan/chewie). Chewie is
✔️ Notifications support
✔️ Picture in Picture support
✔️ DRM support (token, Widevine, FairPlay EZDRM).
✔️ ... and much more!
✔️ ... and much more!
✔️ Volume update on vertical gesture.
✔️ Seek to a specific moment on horizontal gesture


## Documentation
Expand Down
Binary file added fonts/Teko-Bold.ttf
Binary file not shown.
Binary file added fonts/Teko-Light.ttf
Binary file not shown.
Binary file added fonts/Teko-Medium.ttf
Binary file not shown.
Binary file added fonts/Teko-Regular.ttf
Binary file not shown.
Binary file added fonts/Teko-SemiBold.ttf
Binary file not shown.
2 changes: 2 additions & 0 deletions lib/better_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ export 'src/playlist/better_player_playlist_controller.dart';
export 'src/subtitles/better_player_subtitles_configuration.dart';
export 'src/subtitles/better_player_subtitles_source.dart';
export 'src/subtitles/better_player_subtitles_source_type.dart';

export 'src/video_player/video_player.dart' show VideoPlayerValue;
// export 'package:video_player/video_player.dart' show VideoPlayerValue;
11 changes: 11 additions & 0 deletions lib/src/configuration/better_player_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import 'package:flutter/services.dart';
///Master configuration which contains children that configure specific part
///of player.
class BetterPlayerConfiguration {
/// This Video Title Will show in Top Bar.
///
/// Note: Try not to use video title if your Player Theme set to Cupertino
final String videoTitle;

/// Play the video as soon as it's displayed
final bool autoPlay;

Expand All @@ -26,6 +31,9 @@ class BetterPlayerConfiguration {
/// Will fallback to fitting within the space allowed.
final double? aspectRatio;

///
final TextStyle? videoTitleStyle;

/// The placeholder is displayed underneath the Video before it is initialized
/// or played.
final Widget? placeholder;
Expand Down Expand Up @@ -119,6 +127,8 @@ class BetterPlayerConfiguration {
final bool useRootNavigator;

const BetterPlayerConfiguration({
this.videoTitle = "",
this.videoTitleStyle,
this.aspectRatio,
this.autoPlay = false,
this.startAt,
Expand All @@ -135,6 +145,7 @@ class BetterPlayerConfiguration {
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
],

this.systemOverlaysAfterFullScreen = SystemUiOverlay.values,
this.deviceOrientationsAfterFullScreen = const [
DeviceOrientation.portraitUp,
Expand Down
28 changes: 26 additions & 2 deletions lib/src/configuration/better_player_controls_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ class BetterPlayerControlsConfiguration {
///Flag used to enable skip forward and skip back
final bool enableSkips;

///Flag used to enable/disable Back Button
final bool enableBackButton;

///Flag used to enable/disable Dragable GestureController
final bool enableGestureController;

///Flag used to enable/disable Volume Slider
///
///None: Won't work if Dragable GestureController is set to disable
final bool enableVolumeSlider;

///Flag used to enable/disable Brightness Slider
///
///None: Won't work if Dragable GestureController is set to disable
final bool enableBrightnessSlider;

///Progress bar played color
final Color progressBarPlayedColor;

Expand Down Expand Up @@ -137,6 +153,9 @@ class BetterPlayerControlsConfiguration {
///Icon of the audios menu item from overflow menu
final IconData audioTracksIcon;

///Icon of the Top Bar Back Button
final IconData backButtonIcon;

///Color of overflow menu icons
final Color overflowMenuIconsColor;

Expand Down Expand Up @@ -181,8 +200,12 @@ class BetterPlayerControlsConfiguration {
this.enablePlayPause = true,
this.enableSkips = true,
this.enableAudioTracks = true,
this.progressBarPlayedColor = Colors.white,
this.progressBarHandleColor = Colors.white,
this.enableBackButton = true,
this.enableGestureController = true,
this.enableVolumeSlider = true,
this.enableBrightnessSlider = false,
this.progressBarPlayedColor = Colors.red,
this.progressBarHandleColor = const Color.fromARGB(255, 247, 47, 33),
this.progressBarBufferedColor = Colors.white70,
this.progressBarBackgroundColor = Colors.white60,
this.controlsHideTime = const Duration(milliseconds: 300),
Expand All @@ -205,6 +228,7 @@ class BetterPlayerControlsConfiguration {
this.qualitiesIcon = Icons.hd_outlined,
this.subtitlesIcon = Icons.closed_caption_outlined,
this.audioTracksIcon = Icons.audiotrack_outlined,
this.backButtonIcon = Icons.arrow_back_ios_rounded,
this.overflowMenuIconsColor = Colors.black,
this.forwardSkipTimeInMilliseconds = 10000,
this.backwardSkipTimeInMilliseconds = 10000,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'dart:async';
import 'package:better_player/src/models/show_slider_values.dart';
import 'package:flutter/material.dart';

class VolumeBrightnessCupertinoWidget extends StatefulWidget {
final StreamController<double?> value;
final StreamController<ShowSliderValues?> showSlider;
const VolumeBrightnessCupertinoWidget(
{Key? key, required this.value, required this.showSlider})
: super(key: key);

@override
State<VolumeBrightnessCupertinoWidget> createState() =>
_VolumeBrightnessCupertinoWidgetState();
}

class _VolumeBrightnessCupertinoWidgetState
extends State<VolumeBrightnessCupertinoWidget> {
int textValue = 0;
double sliderValue = 0;
double value = 0;
@override
void initState() {
super.initState();

widget.value.stream.listen((event) {
setState(() {
value = event ?? 0;
sliderValue = value / 100;
textValue = value.toInt();
print(textValue);
});
});
}

@override
Widget build(BuildContext context) {
return StreamBuilder<ShowSliderValues?>(
stream: widget.showSlider.stream,
builder: (context, snapshot) {
value = snapshot.data != null ? snapshot.data!.value : 0;
if (snapshot.hasData) {
ShowSliderValues data =
snapshot.data ?? ShowSliderValues(showLeft: true, value: 0);
return Container(
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 60),
child: Align(
alignment: data.showLeft
? Alignment.centerLeft
: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"${textValue}",
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontFamily: "teko",
fontWeight: FontWeight.w400),
),
SizedBox(
height: 15,
),
SizedBox(
height: 80,
child: RotatedBox(
quarterTurns: -1,
child: LinearProgressIndicator(
minHeight: 12,
value: sliderValue,
color: Colors.red,
borderRadius: BorderRadius.circular(6),
backgroundColor: Colors.white24,
),
),
),
SizedBox(height: 10),
Icon(
data.showLeft ? Icons.volume_up : Icons.brightness_4,
color: Colors.white,
)
]),
),
);
} else {
return Container();
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'dart:async';
import 'package:better_player/src/models/show_slider_values.dart';
import 'package:flutter/material.dart';

class VolumeBrightnessMaterialWidget extends StatefulWidget {
final StreamController<double?> value;
final StreamController<ShowSliderValues?> showSlider;
const VolumeBrightnessMaterialWidget(
{Key? key, required this.value, required this.showSlider})
: super(key: key);

@override
State<VolumeBrightnessMaterialWidget> createState() =>
_VolumeBrightnessMaterialWidgetState();
}

class _VolumeBrightnessMaterialWidgetState
extends State<VolumeBrightnessMaterialWidget> {
int textValue = 0;
double sliderValue = 0;
double value = 0;
@override
void initState() {
super.initState();

widget.value.stream.listen((event) {
setState(() {
value = event ?? 0;
sliderValue = value / 100;
textValue = value.toInt();
print(textValue);
});
});
}

@override
Widget build(BuildContext context) {
return StreamBuilder<ShowSliderValues?>(
stream: widget.showSlider.stream,
builder: (context, snapshot) {
value = snapshot.data != null ? snapshot.data!.value : 0;
if (snapshot.hasData) {
ShowSliderValues data =
snapshot.data ?? ShowSliderValues(showLeft: true, value: 0);
return Container(
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 60),
child: Align(
alignment: data.showLeft
? Alignment.centerLeft
: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"${textValue}",
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontFamily: "teko",
fontWeight: FontWeight.w400),
),
SizedBox(
height: 15,
),
SizedBox(
height: 80,
child: RotatedBox(
quarterTurns: -1,
child: LinearProgressIndicator(
minHeight: 12,
value: sliderValue,
color: Colors.red,
borderRadius: BorderRadius.circular(6),
backgroundColor: Colors.white24,
),
),
),
SizedBox(height: 10),
Icon(
data.showLeft ? Icons.volume_up : Icons.brightness_4,
color: Colors.white,
)
]),
),
);
} else {
return Container();
}
});
}
}
12 changes: 5 additions & 7 deletions lib/src/controls/better_player_controls_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,11 @@ abstract class BetterPlayerControlsState<T extends StatefulWidget>
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Container(
margin: EdgeInsets.only(bottom: 20),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
decoration: BoxDecoration(
color: betterPlayerControlsConfiguration.overflowModalColor,
/*shape: RoundedRectangleBorder(side: Bor,borderRadius: 24,)*/
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24.0),
topRight: Radius.circular(24.0)),
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
child: Column(
children: children,
Expand All @@ -488,18 +486,18 @@ abstract class BetterPlayerControlsState<T extends StatefulWidget>
useRootNavigator:
betterPlayerController?.betterPlayerConfiguration.useRootNavigator ??
false,
constraints: BoxConstraints(maxWidth: 350),
builder: (context) {
return SafeArea(
top: false,
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Container(
margin: EdgeInsets.only(bottom: 20),
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
decoration: BoxDecoration(
color: betterPlayerControlsConfiguration.overflowModalColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24.0),
topRight: Radius.circular(24.0)),
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
child: Column(
children: children,
Expand Down
Loading