Skip to content
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
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This plugin built upon flutter's official [`video_player`](https://pub.dartlang.
- Custom overlay
- Custom progress bar
- Custom labels
- Video Watermark (With ability to show/hide the watermark from the controller)
- `Change video quality` (for vimeo and youtube)
- Enable/disable full-screen player
- support for live youtube video
Expand Down Expand Up @@ -299,6 +300,34 @@ Widget build(BuildContext context) {
}
```

## Add Video Watermark

```dart
@override
Widget build(BuildContext context) {
return Scaffold(
body: PodVideoPlayer(
controller: controller,
videoWatermark: const Center(
child: FlutterLogo(size: 150),
),
),
);
}
```

You can also use the `controller` to show/hide the watermark at any time.

```dart
// show watermark
controller.showWatermark();

// hide watermark
controller.hideWatermark();
```

**Note:** The watermark is **hidden** by default.

## How to play video from youtube

---
Expand Down
14 changes: 14 additions & 0 deletions example/lib/screens/cutom_video_controllers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
matchFrameAspectRatioToVideo: true,
matchVideoAspectRatioToFrame: true,
videoTitle: videoTitle,
videoWatermark: const Center(
child: FlutterLogo(size: 150),
),
),
Padding(
padding: const EdgeInsets.all(12.0),
Expand Down Expand Up @@ -165,6 +168,17 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
onPressed: () {
controller.hideOverlay();
}),
sizeH20,
_iconButton('Show Watermark', Icons.verified_rounded,
onPressed: () {
controller.showWatermark();
}),
sizeH20,
_iconButton('Hide Watermark', Icons.verified_outlined,
onPressed: () {
controller.hideWatermark();
}),
sizeH20,
_iconButton('Backward video 5s', Icons.replay_5_rounded,
onPressed: () {
controller.doubleTapVideoBackward(5);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/controllers/pod_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,10 @@ class PodPlayerController {

/// Show overlay of video
void showOverlay() => _ctr.isShowOverlay(true);

/// Hide watermark of video
void hideWatermark() => _ctr.isShowWatermark(false);

/// Show watermark of video
void showWatermark() => _ctr.isShowWatermark(true);
}
1 change: 1 addition & 0 deletions lib/src/controllers/pod_ui_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class _PodUiController extends _PodBaseController {
Widget Function(OverLayOptions options)? overlayBuilder;
Widget? videoTitle;
DecorationImage? videoThumbnail;
Widget? videoWatermark;

/// Callback when fullscreen mode changes
Future<void> Function(bool isFullScreen)? onToggleFullScreen;
Expand Down
10 changes: 10 additions & 0 deletions lib/src/controllers/pod_video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class _PodVideoController extends _PodUiController {
Timer? showOverlayTimer1;

bool isOverlayVisible = true;
bool isWatermarkVisible = false;
bool isLooping = false;
bool isFullScreen = false;
bool isvideoPlaying = false;
Expand Down Expand Up @@ -111,6 +112,15 @@ class _PodVideoController extends _PodUiController {
});
}

/// Toggle watermark visibility.
void isShowWatermark(bool val) {
if (isWatermarkVisible == val) return;

isWatermarkVisible = val;
update(['watermark']);
update(['update-all']);
}

///overlay above video contrller
void toggleVideoOverlay() {
if (!isOverlayVisible) {
Expand Down
9 changes: 8 additions & 1 deletion lib/src/pod_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ part 'widgets/core/overlays/mobile_overlay.dart';

part 'widgets/core/overlays/overlays.dart';

part 'widgets/core/video_watermark.dart';

part 'widgets/core/overlays/web_dropdown_menu.dart';

part 'widgets/core/overlays/web_overlay.dart';
Expand All @@ -45,6 +47,9 @@ class PodVideoPlayer extends StatefulWidget {
final Color? backgroundColor;
final DecorationImage? videoThumbnail;

/// Optional watermark widget that is shown on the top of the video.
final Widget? videoWatermark;

/// Optional callback, fired when full screen mode toggles.
///
/// Important: If this method is set, the configuration of [DeviceOrientation]
Expand Down Expand Up @@ -72,6 +77,7 @@ class PodVideoPlayer extends StatefulWidget {
this.videoThumbnail,
this.onToggleFullScreen,
this.onLoading,
this.videoWatermark,
}) {
addToUiController();
}
Expand All @@ -90,7 +96,8 @@ class PodVideoPlayer extends StatefulWidget {
..videoTitle = videoTitle
..onToggleFullScreen = onToggleFullScreen
..onLoading = onLoading
..videoThumbnail = videoThumbnail;
..videoThumbnail = videoThumbnail
..videoWatermark = videoWatermark;
}

@override
Expand Down
1 change: 1 addition & 0 deletions lib/src/widgets/core/pod_core_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class _PodCoreVideoPlayer extends StatelessWidget {
},
),
),
_VideoWatermark(tag: tag),
_VideoOverlays(tag: tag),
IgnorePointer(
child: GetBuilder<PodGetXVideoController>(
Expand Down
26 changes: 26 additions & 0 deletions lib/src/widgets/core/video_watermark.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
part of 'package:pod_player/src/pod_player.dart';

class _VideoWatermark extends StatelessWidget {
final String tag;

const _VideoWatermark({
required this.tag,
});

@override
Widget build(BuildContext context) {
return IgnorePointer(
child: GetBuilder<PodGetXVideoController>(
tag: tag,
id: 'watermark',
builder: (podCtr) {
if (podCtr.videoWatermark == null || !podCtr.isWatermarkVisible) {
return const SizedBox.shrink();
}

return podCtr.videoWatermark!;
},
),
);
}
}