From f7a5038f868f64c4e4ba950d4daf743f188f8d89 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Mon, 18 Dec 2023 17:41:31 +0300 Subject: [PATCH 01/15] added some methods in controller --- .../controllers/pod_player_controller.dart | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/src/controllers/pod_player_controller.dart b/lib/src/controllers/pod_player_controller.dart index 229ce884..c54e9ea7 100644 --- a/lib/src/controllers/pod_player_controller.dart +++ b/lib/src/controllers/pod_player_controller.dart @@ -108,6 +108,10 @@ class PodPlayerController { PodVideoPlayerType get videoPlayerType => _ctr.videoPlayerType; + int? get vimeoPlayingVideoQuality => _ctr.vimeoPlayingVideoQuality; + + String get currentPaybackSpeed => _ctr.currentPaybackSpeed; + // Future initialize() async => _ctr.videoCtr?.initialize; //! video positions @@ -140,6 +144,15 @@ class PodPlayerController { ); } + /// change video quality + void changeQualityVideo(int quality) { + _ctr.changeVideoQuality(quality); + } + + void setPlaybackSpeed(String speed) { + _ctr.setVideoPlayBack(speed); + } + /// Remove registered listeners void removeListener(VoidCallback listener) { _checkAndWaitTillInitialized().then( @@ -160,6 +173,21 @@ class PodPlayerController { _ctr.isMute ? await _ctr.unMute() : await _ctr.mute(); } + /// toggle looping + Future toggleLooping() { + return _ctr.toggleLooping(); + } + + /// enable looping + Future enableLooping() { + return _ctr.setLooping(true); + } + + /// disable looping + Future disableLooping() { + return _ctr.setLooping(false); + } + ///Dispose pod video player controller void dispose() { _isCtrInitialised = false; @@ -185,8 +213,7 @@ class PodPlayerController { ); //Change double tap duration - void setDoubeTapForwarDuration(int seconds) => - _ctr.doubleTapForwardSeconds = seconds; + void setDoubeTapForwarDuration(int seconds) => _ctr.doubleTapForwardSeconds = seconds; ///Jumps to specific position of the video Future videoSeekTo(Duration moment) async { From d8bb2c25a7922813e9386ba5958c1debbf24ed06 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Tue, 19 Dec 2023 08:43:22 +0300 Subject: [PATCH 02/15] refactoring --- example/pubspec.yaml | 2 +- lib/src/controllers/pod_player_controller.dart | 3 ++- pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 687fec49..2bd9be4c 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=2.16.1 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: flutter: diff --git a/lib/src/controllers/pod_player_controller.dart b/lib/src/controllers/pod_player_controller.dart index c54e9ea7..e039edbe 100644 --- a/lib/src/controllers/pod_player_controller.dart +++ b/lib/src/controllers/pod_player_controller.dart @@ -213,7 +213,8 @@ class PodPlayerController { ); //Change double tap duration - void setDoubeTapForwarDuration(int seconds) => _ctr.doubleTapForwardSeconds = seconds; + void setDoubeTapForwarDuration(int seconds) => + _ctr.doubleTapForwardSeconds = seconds; ///Jumps to specific position of the video Future videoSeekTo(Duration moment) async { diff --git a/pubspec.yaml b/pubspec.yaml index 88647f4e..96218375 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.2.1 homepage: https://github.com/newtaDev/pod_player environment: - sdk: ">=2.17.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ">=1.17.0" dependencies: From d44e93bb3627403e3ed05befbb0164b73174d292 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 22 Dec 2023 16:16:55 +0300 Subject: [PATCH 03/15] fix overlay on web --- lib/src/widgets/core/pod_core_player.dart | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/src/widgets/core/pod_core_player.dart b/lib/src/widgets/core/pod_core_player.dart index 7a7a3e47..847a27b7 100644 --- a/lib/src/widgets/core/pod_core_player.dart +++ b/lib/src/widgets/core/pod_core_player.dart @@ -18,9 +18,7 @@ class _PodCoreVideoPlayer extends StatelessWidget { builder: (ctrx) { return RawKeyboardListener( autofocus: true, - focusNode: - (podCtr.isFullScreen ? FocusNode() : podCtr.keyboardFocusWeb) ?? - FocusNode(), + focusNode: (podCtr.isFullScreen ? FocusNode() : podCtr.keyboardFocusWeb) ?? FocusNode(), onKey: (value) => podCtr.onKeyBoardEvents( event: value, appContext: ctrx, @@ -83,7 +81,7 @@ class _PodCoreVideoPlayer extends StatelessWidget { ), ); - if (kIsWeb) { + if (kIsWeb && podCtr.overlayBuilder == null) { switch (podCtr.podVideoState) { case PodVideoState.loading: return loadingWidget; @@ -132,18 +130,17 @@ class _PodCoreVideoPlayer extends StatelessWidget { : GetBuilder( tag: tag, id: 'overlay', - builder: (podCtr) => podCtr.isOverlayVisible || - !podCtr.alwaysShowProgressBar - ? const SizedBox() - : Align( - alignment: Alignment.bottomCenter, - child: PodProgressBar( - tag: tag, - alignment: Alignment.bottomCenter, - podProgressBarConfig: - podCtr.podProgressBarConfig, - ), - ), + builder: (podCtr) => + podCtr.isOverlayVisible || !podCtr.alwaysShowProgressBar + ? const SizedBox() + : Align( + alignment: Alignment.bottomCenter, + child: PodProgressBar( + tag: tag, + alignment: Alignment.bottomCenter, + podProgressBarConfig: podCtr.podProgressBarConfig, + ), + ), ), ), ], From 47848d060fad80aa1a7d4d3f306c6fb4ed6d8ce1 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Wed, 27 Dec 2023 12:08:46 +0300 Subject: [PATCH 04/15] added context as parameter to enable full screen --- .../pod_getx_video_controller.dart | 2 +- .../controllers/pod_player_controller.dart | 7 +++--- lib/src/controllers/pod_video_controller.dart | 23 +++++++++++-------- .../widgets/core/overlays/web_overlay.dart | 18 +++++---------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/lib/src/controllers/pod_getx_video_controller.dart b/lib/src/controllers/pod_getx_video_controller.dart index 7a46d30d..f95d7bce 100644 --- a/lib/src/controllers/pod_getx_video_controller.dart +++ b/lib/src/controllers/pod_getx_video_controller.dart @@ -248,7 +248,7 @@ class PodGetXVideoController extends _PodGesturesController { } } else { uni_html.document.documentElement?.requestFullscreen(); - enableFullScreen(tag); + enableFullScreen(tag, context); } } diff --git a/lib/src/controllers/pod_player_controller.dart b/lib/src/controllers/pod_player_controller.dart index e039edbe..08b9667d 100644 --- a/lib/src/controllers/pod_player_controller.dart +++ b/lib/src/controllers/pod_player_controller.dart @@ -213,8 +213,7 @@ class PodPlayerController { ); //Change double tap duration - void setDoubeTapForwarDuration(int seconds) => - _ctr.doubleTapForwardSeconds = seconds; + void setDoubeTapForwarDuration(int seconds) => _ctr.doubleTapForwardSeconds = seconds; ///Jumps to specific position of the video Future videoSeekTo(Duration moment) async { @@ -255,9 +254,9 @@ class PodPlayerController { /// /// If onToggleFullScreen is set, you must handle the device /// orientation by yourself. - void enableFullScreen() { + void enableFullScreen({BuildContext? context}) { uni_html.document.documentElement?.requestFullscreen(); - _ctr.enableFullScreen(getTag); + _ctr.enableFullScreen(getTag, context); } /// Disables fullscreen mode. diff --git a/lib/src/controllers/pod_video_controller.dart b/lib/src/controllers/pod_video_controller.dart index 0a0d4ea6..654b8a7f 100644 --- a/lib/src/controllers/pod_video_controller.dart +++ b/lib/src/controllers/pod_video_controller.dart @@ -159,7 +159,10 @@ class _PodVideoController extends _PodUiController { update(['update-all']); } - Future enableFullScreen(String tag) async { + Future enableFullScreen( + String tag, + BuildContext? context, + ) async { podLog('-full-screen-enable-entred'); if (!isFullScreen) { if (onToggleFullScreen != null) { @@ -176,7 +179,7 @@ class _PodVideoController extends _PodUiController { ]); } - _enableFullScreenView(tag); + _enableFullScreenView(tag, context); isFullScreen = true; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { update(['full-screen']); @@ -222,20 +225,22 @@ class _PodVideoController extends _PodUiController { Navigator.of(fullScreenContext).pop(); } - void _enableFullScreenView(String tag) { + void _enableFullScreenView( + String tag, + BuildContext? context, + ) { if (!isFullScreen) { podLog('full-screen-enabled'); Navigator.push( - mainContext, + context ?? mainContext, PageRouteBuilder( fullscreenDialog: true, pageBuilder: (BuildContext context, _, __) => FullScreenView( tag: tag, ), reverseTransitionDuration: const Duration(milliseconds: 400), - transitionsBuilder: (context, animation, secondaryAnimation, child) => - FadeTransition( + transitionsBuilder: (context, animation, secondaryAnimation, child) => FadeTransition( opacity: animation, child: child, ), @@ -248,10 +253,8 @@ class _PodVideoController extends _PodUiController { String calculateVideoDuration(Duration duration) { final totalHour = duration.inHours == 0 ? '' : '${duration.inHours}:'; final totalMinute = duration.toString().split(':')[1]; - final totalSeconds = (duration - Duration(minutes: duration.inMinutes)) - .inSeconds - .toString() - .padLeft(2, '0'); + final totalSeconds = + (duration - Duration(minutes: duration.inMinutes)).inSeconds.toString().padLeft(2, '0'); final String videoLength = '$totalHour$totalMinute:$totalSeconds'; return videoLength; } diff --git a/lib/src/widgets/core/overlays/web_overlay.dart b/lib/src/widgets/core/overlays/web_overlay.dart index 3371b2fc..049b175f 100644 --- a/lib/src/widgets/core/overlays/web_overlay.dart +++ b/lib/src/widgets/core/overlays/web_overlay.dart @@ -107,16 +107,12 @@ class _WebOverlayBottomControlles extends StatelessWidget { id: 'volume', builder: (podCtr) => MaterialIconButton( toolTipMesg: podCtr.isMute - ? podCtr.podPlayerLabels.unmute ?? - 'Unmute${kIsWeb ? ' (m)' : ''}' - : podCtr.podPlayerLabels.mute ?? - 'Mute${kIsWeb ? ' (m)' : ''}', + ? podCtr.podPlayerLabels.unmute ?? 'Unmute${kIsWeb ? ' (m)' : ''}' + : podCtr.podPlayerLabels.mute ?? 'Mute${kIsWeb ? ' (m)' : ''}', color: itemColor, onPressed: podCtr.toggleMute, child: Icon( - podCtr.isMute - ? Icons.volume_off_rounded - : Icons.volume_up_rounded, + podCtr.isMute ? Icons.volume_off_rounded : Icons.volume_up_rounded, ), ), ), @@ -167,9 +163,7 @@ class _WebOverlayBottomControlles extends StatelessWidget { color: itemColor, onPressed: () => _onFullScreenToggle(podCtr, context), child: Icon( - podCtr.isFullScreen - ? Icons.fullscreen_exit - : Icons.fullscreen, + podCtr.isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen, ), ), ], @@ -200,10 +194,10 @@ class _WebOverlayBottomControlles extends StatelessWidget { } else { if (kIsWeb) { uni_html.document.documentElement?.requestFullscreen(); - podCtr.enableFullScreen(tag); + podCtr.enableFullScreen(tag, context); return; } else { - podCtr.enableFullScreen(tag); + podCtr.enableFullScreen(tag, context); } } } else { From 886a20fe7fa9886231e8ff5b757828f52e9f5787 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Wed, 27 Dec 2023 12:19:22 +0300 Subject: [PATCH 05/15] fix --- lib/src/widgets/core/overlays/mobile_bottomsheet.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart index 5cf988e9..de924b1b 100644 --- a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart +++ b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart @@ -226,24 +226,21 @@ class _MobileOverlayBottomControlles extends StatelessWidget { toolTipMesg: podCtr.isFullScreen ? podCtr.podPlayerLabels.exitFullScreen ?? 'Exit full screen${kIsWeb ? ' (f)' : ''}' - : podCtr.podPlayerLabels.fullscreen ?? - 'Fullscreen${kIsWeb ? ' (f)' : ''}', + : podCtr.podPlayerLabels.fullscreen ?? 'Fullscreen${kIsWeb ? ' (f)' : ''}', color: itemColor, onPressed: () { if (podCtr.isOverlayVisible) { if (podCtr.isFullScreen) { podCtr.disableFullScreen(context, tag); } else { - podCtr.enableFullScreen(tag); + podCtr.enableFullScreen(tag, context); } } else { podCtr.toggleVideoOverlay(); } }, child: Icon( - podCtr.isFullScreen - ? Icons.fullscreen_exit - : Icons.fullscreen, + podCtr.isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen, ), ), ], From c7c545a0685b0d3432b8871099ea9b4d267f5b34 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 00:47:29 +0300 Subject: [PATCH 06/15] update dependencies --- .vscode/launch.json | 45 +++++++++++++++++++ README.md | 10 ++--- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 15 ++++--- example/ios/Runner.xcodeproj/project.pbxproj | 8 ++-- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../lib/examples/load_vimeo_from_urls.dart | 4 +- .../lib/examples/load_youtube_from_urls.dart | 4 +- example/lib/examples/play_list_of_videos.dart | 8 ++-- .../play_videos_list_dynamically.dart | 9 ++-- example/lib/main.dart | 4 +- .../lib/screens/cutom_video_controllers.dart | 2 +- example/lib/screens/from_asset.dart | 2 +- example/lib/screens/from_network.dart | 2 +- example/lib/screens/from_network_urls.dart | 2 +- example/lib/screens/from_vimeo_id.dart | 2 +- .../lib/screens/from_vimeo_private_id.dart | 2 +- example/lib/screens/from_youtube.dart | 2 +- .../Flutter/GeneratedPluginRegistrant.swift | 4 +- example/pubspec.yaml | 8 ++-- .../pod_getx_video_controller.dart | 12 ----- lib/src/controllers/pod_video_controller.dart | 37 ++++++++------- .../core/overlays/web_dropdown_menu.dart | 3 -- lib/src/widgets/doubble_tap_effect.dart | 2 +- lib/src/widgets/full_screen_view.dart | 5 +-- pubspec.yaml | 16 +++---- 27 files changed, 124 insertions(+), 90 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..f686ab44 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "pod_player", + "request": "launch", + "type": "dart" + }, + { + "name": "pod_player (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "pod_player (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + }, + { + "name": "example", + "cwd": "example", + "request": "launch", + "type": "dart" + }, + { + "name": "example (profile mode)", + "cwd": "example", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "example (release mode)", + "cwd": "example", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 4dd4015c..071659be 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromNetwork extends StatefulWidget { - const PlayVideoFromNetwork({Key? key}) : super(key: key); + const PlayVideoFromNetwork({super.key}); @override State createState() => _PlayVideoFromNetworkState(); @@ -308,7 +308,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromYoutube extends StatefulWidget { - const PlayVideoFromYoutube({Key? key}) : super(key: key); + const PlayVideoFromYoutube({super.key}); @override State createState() => _PlayVideoFromYoutubeState(); @@ -350,7 +350,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromVimeo extends StatefulWidget { - const PlayVideoFromVimeo({Key? key}) : super(key: key); + const PlayVideoFromVimeo({super.key}); @override State createState() => _PlayVideoFromVimeoState(); @@ -392,7 +392,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromVimeo extends StatefulWidget { - const PlayVideoFromVimeo({Key? key}) : super(key: key); + const PlayVideoFromVimeo({super.key}); @override State createState() => _PlayVideoFromVimeoState(); @@ -434,7 +434,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromVimeoPrivateVideo extends StatefulWidget { - const PlayVideoFromVimeoPrivateVideo({Key? key}) : super(key: key); + const PlayVideoFromVimeoPrivateVideo({super.key}); @override State createState() => diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105..7c569640 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 88359b22..279576f3 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +# platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 2d8232cd..03fbbd21 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -4,13 +4,14 @@ PODS: - Flutter - video_player_avfoundation (0.0.1): - Flutter + - FlutterMacOS - wakelock_plus (0.0.1): - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`) + - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) - wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`) EXTERNAL SOURCES: @@ -19,16 +20,16 @@ EXTERNAL SOURCES: package_info_plus: :path: ".symlinks/plugins/package_info_plus/ios" video_player_avfoundation: - :path: ".symlinks/plugins/video_player_avfoundation/ios" + :path: ".symlinks/plugins/video_player_avfoundation/darwin" wakelock_plus: :path: ".symlinks/plugins/wakelock_plus/ios" SPEC CHECKSUMS: - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 - video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85 + video_player_avfoundation: e9e6f9cae7d7a6d9b43519b0aab382bca60fcfd1 wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47 -PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.11.2 +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 5b1c9f9c..8b6b52ed 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -342,7 +342,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -420,7 +420,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -469,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..a6b826db 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ args) { } class VimeoApp extends StatelessWidget { - const VimeoApp({Key? key}) : super(key: key); + const VimeoApp({super.key}); @override Widget build(BuildContext context) { @@ -20,7 +20,7 @@ class VimeoApp extends StatelessWidget { } class VimeoVideoViewer extends StatefulWidget { - const VimeoVideoViewer({Key? key}) : super(key: key); + const VimeoVideoViewer({super.key}); @override State createState() => VimeoVideoViewerState(); diff --git a/example/lib/examples/load_youtube_from_urls.dart b/example/lib/examples/load_youtube_from_urls.dart index 013840a6..a74cf973 100644 --- a/example/lib/examples/load_youtube_from_urls.dart +++ b/example/lib/examples/load_youtube_from_urls.dart @@ -6,7 +6,7 @@ void main(List args) { } class YoutubeApp extends StatelessWidget { - const YoutubeApp({Key? key}) : super(key: key); + const YoutubeApp({super.key}); @override Widget build(BuildContext context) { @@ -21,7 +21,7 @@ class YoutubeApp extends StatelessWidget { } class YoutubeVideoViewer extends StatefulWidget { - const YoutubeVideoViewer({Key? key}) : super(key: key); + const YoutubeVideoViewer({super.key}); @override State createState() => _YoutubeVideoViewerState(); diff --git a/example/lib/examples/play_list_of_videos.dart b/example/lib/examples/play_list_of_videos.dart index ed695d34..8c21809d 100644 --- a/example/lib/examples/play_list_of_videos.dart +++ b/example/lib/examples/play_list_of_videos.dart @@ -7,7 +7,7 @@ void main(List args) { } class ListOfVideosApp extends StatelessWidget { - const ListOfVideosApp({Key? key}) : super(key: key); + const ListOfVideosApp({super.key}); @override Widget build(BuildContext context) { @@ -82,8 +82,7 @@ class ListOfVideosApp extends StatelessWidget { class ListOfVideosScreen extends StatelessWidget { final List videosList; - const ListOfVideosScreen({Key? key, required this.videosList}) - : super(key: key); + const ListOfVideosScreen({super.key, required this.videosList}); @override Widget build(BuildContext context) { @@ -100,8 +99,7 @@ class ListOfVideosScreen extends StatelessWidget { class ListOfVideosViewer extends StatefulWidget { final List videosList; - const ListOfVideosViewer({Key? key, required this.videosList}) - : super(key: key); + const ListOfVideosViewer({super.key, required this.videosList}); @override State createState() => _ListOfVideosViewerState(); diff --git a/example/lib/examples/play_videos_list_dynamically.dart b/example/lib/examples/play_videos_list_dynamically.dart index 635037a1..3229e928 100644 --- a/example/lib/examples/play_videos_list_dynamically.dart +++ b/example/lib/examples/play_videos_list_dynamically.dart @@ -9,7 +9,7 @@ void main(List args) { } class ListOfVideosApp extends StatelessWidget { - const ListOfVideosApp({Key? key}) : super(key: key); + const ListOfVideosApp({super.key}); @override Widget build(BuildContext context) { @@ -50,8 +50,7 @@ class ListOfVideosApp extends StatelessWidget { class ListOfVideosScreen extends StatelessWidget { final List controllers; - const ListOfVideosScreen({Key? key, required this.controllers}) - : super(key: key); + const ListOfVideosScreen({super.key, required this.controllers}); @override Widget build(BuildContext context) { @@ -76,10 +75,10 @@ class VideoViewer extends StatefulWidget { final List controllers; const VideoViewer({ - Key? key, + super.key, required this.controller, required this.controllers, - }) : super(key: key); + }); @override State createState() => VideoViewerState(); diff --git a/example/lib/main.dart b/example/lib/main.dart index ffe73f8e..9a890024 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,7 +15,7 @@ void main() { } class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); + const MyApp({super.key}); @override Widget build(BuildContext context) { @@ -37,7 +37,7 @@ class MyApp extends StatelessWidget { } class MainPage extends StatefulWidget { - const MainPage({Key? key}) : super(key: key); + const MainPage({super.key}); @override State createState() => _MainPageState(); diff --git a/example/lib/screens/cutom_video_controllers.dart b/example/lib/screens/cutom_video_controllers.dart index ce511edb..5435b08b 100644 --- a/example/lib/screens/cutom_video_controllers.dart +++ b/example/lib/screens/cutom_video_controllers.dart @@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class CustomVideoControlls extends StatefulWidget { - const CustomVideoControlls({Key? key}) : super(key: key); + const CustomVideoControlls({super.key}); @override State createState() => _CustomVideoControllsState(); diff --git a/example/lib/screens/from_asset.dart b/example/lib/screens/from_asset.dart index 1a63f055..3dfbacea 100644 --- a/example/lib/screens/from_asset.dart +++ b/example/lib/screens/from_asset.dart @@ -2,7 +2,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromAsset extends StatefulWidget { - const PlayVideoFromAsset({Key? key}) : super(key: key); + const PlayVideoFromAsset({super.key}); @override State createState() => _PlayVideoFromAssetState(); diff --git a/example/lib/screens/from_network.dart b/example/lib/screens/from_network.dart index dd5739a7..40d28bc7 100644 --- a/example/lib/screens/from_network.dart +++ b/example/lib/screens/from_network.dart @@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class PlayVideoFromNetwork extends StatefulWidget { - const PlayVideoFromNetwork({Key? key}) : super(key: key); + const PlayVideoFromNetwork({super.key}); @override State createState() => _PlayVideoFromAssetState(); diff --git a/example/lib/screens/from_network_urls.dart b/example/lib/screens/from_network_urls.dart index 3c0ab641..ede5f0fe 100644 --- a/example/lib/screens/from_network_urls.dart +++ b/example/lib/screens/from_network_urls.dart @@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class PlayVideoFromNetworkQualityUrls extends StatefulWidget { - const PlayVideoFromNetworkQualityUrls({Key? key}) : super(key: key); + const PlayVideoFromNetworkQualityUrls({super.key}); @override State createState() => diff --git a/example/lib/screens/from_vimeo_id.dart b/example/lib/screens/from_vimeo_id.dart index 93a67efb..0beef4e0 100644 --- a/example/lib/screens/from_vimeo_id.dart +++ b/example/lib/screens/from_vimeo_id.dart @@ -2,7 +2,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromVimeoId extends StatefulWidget { - const PlayVideoFromVimeoId({Key? key}) : super(key: key); + const PlayVideoFromVimeoId({super.key}); @override State createState() => _PlayVideoFromVimeoIdState(); diff --git a/example/lib/screens/from_vimeo_private_id.dart b/example/lib/screens/from_vimeo_private_id.dart index da1baec0..c417d9c7 100644 --- a/example/lib/screens/from_vimeo_private_id.dart +++ b/example/lib/screens/from_vimeo_private_id.dart @@ -2,7 +2,7 @@ import 'package:pod_player/pod_player.dart'; import 'package:flutter/material.dart'; class PlayVideoFromVimeoPrivateId extends StatefulWidget { - const PlayVideoFromVimeoPrivateId({Key? key}) : super(key: key); + const PlayVideoFromVimeoPrivateId({super.key}); @override State createState() => diff --git a/example/lib/screens/from_youtube.dart b/example/lib/screens/from_youtube.dart index 8c10ec69..016e1f63 100644 --- a/example/lib/screens/from_youtube.dart +++ b/example/lib/screens/from_youtube.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:pod_player/pod_player.dart'; class PlayVideoFromYoutube extends StatefulWidget { - const PlayVideoFromYoutube({Key? key}) : super(key: key); + const PlayVideoFromYoutube({super.key}); @override State createState() => _PlayVideoFromVimeoIdState(); diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index f26940ad..8e40e9f0 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,9 +6,11 @@ import FlutterMacOS import Foundation import package_info_plus +import video_player_avfoundation import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) + FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 2bd9be4c..44c90d0d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: "none" version: 1.0.0+1 environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.2.4 <4.0.0" dependencies: flutter: @@ -15,14 +15,14 @@ dependencies: pod_player: path: ../ - cupertino_icons: ^1.0.5 - visibility_detector: ^0.3.3 + cupertino_icons: ^1.0.6 + visibility_detector: ^0.4.0+2 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.1 + flutter_lints: ^3.0.1 flutter: uses-material-design: true diff --git a/lib/src/controllers/pod_getx_video_controller.dart b/lib/src/controllers/pod_getx_video_controller.dart index f95d7bce..cb1367c5 100644 --- a/lib/src/controllers/pod_getx_video_controller.dart +++ b/lib/src/controllers/pod_getx_video_controller.dart @@ -93,7 +93,6 @@ class PodGetXVideoController extends _PodGesturesController { httpHeaders: playVideoFrom.httpHeaders, ); playingVideoUrl = playVideoFrom.dataSource; - break; case PodVideoPlayerType.networkQualityUrls: final url = await getUrlFromVideoQualityUrls( qualityList: podPlayerConfig.videoQualityPriority, @@ -110,7 +109,6 @@ class PodGetXVideoController extends _PodGesturesController { ); playingVideoUrl = url; - break; case PodVideoPlayerType.youtube: final urls = await getVideoQualityUrlsFromYoutube( playVideoFrom.dataSource!, @@ -131,7 +129,6 @@ class PodGetXVideoController extends _PodGesturesController { ); playingVideoUrl = url; - break; case PodVideoPlayerType.vimeo: await getQualityUrlsFromVimeoId( playVideoFrom.dataSource!, @@ -151,7 +148,6 @@ class PodGetXVideoController extends _PodGesturesController { ); playingVideoUrl = url; - break; case PodVideoPlayerType.asset: /// @@ -163,7 +159,6 @@ class PodGetXVideoController extends _PodGesturesController { ); playingVideoUrl = playVideoFrom.dataSource; - break; case PodVideoPlayerType.file: if (kIsWeb) { throw Exception('file doesnt support web'); @@ -176,7 +171,6 @@ class PodGetXVideoController extends _PodGesturesController { videoPlayerOptions: playVideoFrom.videoPlayerOptions, ); - break; case PodVideoPlayerType.vimeoPrivateVideos: await getQualityUrlsFromVimeoPrivateId( playVideoFrom.dataSource!, @@ -195,8 +189,6 @@ class PodGetXVideoController extends _PodGesturesController { httpHeaders: playVideoFrom.httpHeaders, ); playingVideoUrl = url; - - break; } } @@ -259,18 +251,14 @@ class PodGetXVideoController extends _PodGesturesController { case PodVideoState.playing: if (podPlayerConfig.wakelockEnabled) WakelockPlus.enable(); playVideo(true); - break; case PodVideoState.paused: if (podPlayerConfig.wakelockEnabled) WakelockPlus.disable(); playVideo(false); - break; case PodVideoState.loading: isShowOverlay(true); - break; case PodVideoState.error: if (podPlayerConfig.wakelockEnabled) WakelockPlus.disable(); playVideo(false); - break; } } diff --git a/lib/src/controllers/pod_video_controller.dart b/lib/src/controllers/pod_video_controller.dart index 654b8a7f..c827bef6 100644 --- a/lib/src/controllers/pod_video_controller.dart +++ b/lib/src/controllers/pod_video_controller.dart @@ -198,19 +198,21 @@ class _PodVideoController extends _PodUiController { if (onToggleFullScreen != null) { await onToggleFullScreen!(false); } else { - await Future.wait([ - SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - ]), - if (!(defaultTargetPlatform == TargetPlatform.iOS)) ...[ - SystemChrome.setPreferredOrientations(DeviceOrientation.values), - SystemChrome.setEnabledSystemUIMode( - SystemUiMode.manual, - overlays: SystemUiOverlay.values, - ), - ] - ]); + await Future.wait( + [ + SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + ]), + if (!(defaultTargetPlatform == TargetPlatform.iOS)) ...[ + SystemChrome.setPreferredOrientations(DeviceOrientation.values), + SystemChrome.setEnabledSystemUIMode( + SystemUiMode.manual, + overlays: SystemUiOverlay.values, + ), + ], + ], + ); } if (enablePop) _exitFullScreenView(context, tag); @@ -240,7 +242,8 @@ class _PodVideoController extends _PodUiController { tag: tag, ), reverseTransitionDuration: const Duration(milliseconds: 400), - transitionsBuilder: (context, animation, secondaryAnimation, child) => FadeTransition( + transitionsBuilder: (context, animation, secondaryAnimation, child) => + FadeTransition( opacity: animation, child: child, ), @@ -253,8 +256,10 @@ class _PodVideoController extends _PodUiController { String calculateVideoDuration(Duration duration) { final totalHour = duration.inHours == 0 ? '' : '${duration.inHours}:'; final totalMinute = duration.toString().split(':')[1]; - final totalSeconds = - (duration - Duration(minutes: duration.inMinutes)).inSeconds.toString().padLeft(2, '0'); + final totalSeconds = (duration - Duration(minutes: duration.inMinutes)) + .inSeconds + .toString() + .padLeft(2, '0'); final String videoLength = '$totalHour$totalMinute:$totalSeconds'; return videoLength; } diff --git a/lib/src/widgets/core/overlays/web_dropdown_menu.dart b/lib/src/widgets/core/overlays/web_dropdown_menu.dart index 78965f89..783a8999 100644 --- a/lib/src/widgets/core/overlays/web_dropdown_menu.dart +++ b/lib/src/widgets/core/overlays/web_dropdown_menu.dart @@ -68,14 +68,11 @@ class _WebSettingsDropdownState extends State<_WebSettingsDropdown> { switch (settingsMenu) { case 'OUALITY': await _onVimeoQualitySelect(details, podCtr); - break; case 'SPEED': await _onPlaybackSpeedSelect(details, podCtr); - break; case 'LOOP': podCtr.isWebPopupOverlayOpen = false; await podCtr.toggleLooping(); - break; default: podCtr.isWebPopupOverlayOpen = false; } diff --git a/lib/src/widgets/doubble_tap_effect.dart b/lib/src/widgets/doubble_tap_effect.dart index f23915f9..a9570a5a 100644 --- a/lib/src/widgets/doubble_tap_effect.dart +++ b/lib/src/widgets/doubble_tap_effect.dart @@ -199,7 +199,7 @@ class _DoubleTapRippleEffectState extends State fillColor: widget.rippleColor, ), ), - ) + ), ], ), ), diff --git a/lib/src/widgets/full_screen_view.dart b/lib/src/widgets/full_screen_view.dart index e26501ac..d7b77651 100644 --- a/lib/src/widgets/full_screen_view.dart +++ b/lib/src/widgets/full_screen_view.dart @@ -39,8 +39,8 @@ class _FullScreenViewState extends State strokeWidth: 2, ); - return WillPopScope( - onWillPop: () async { + return PopScope( + onPopInvoked: (_) async { if (kIsWeb) { await _podCtr.disableFullScreen( context, @@ -49,7 +49,6 @@ class _FullScreenViewState extends State ); } if (!kIsWeb) await _podCtr.disableFullScreen(context, widget.tag); - return true; }, child: Scaffold( backgroundColor: Colors.black, diff --git a/pubspec.yaml b/pubspec.yaml index 96218375..93fc3da6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,24 +4,24 @@ version: 0.2.1 homepage: https://github.com/newtaDev/pod_player environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.2.4 <4.0.0" flutter: ">=1.17.0" dependencies: flutter: sdk: flutter # services - video_player: ^2.7.0 - http: ^1.1.0 - get: ^4.6.5 - wakelock_plus: ^1.1.1 - universal_html: ^2.2.3 - youtube_explode_dart: ^2.0.1 + video_player: ^2.8.2 + http: ^1.2.0 + get: ^4.6.6 + wakelock_plus: ^1.1.4 + universal_html: ^2.2.4 + youtube_explode_dart: ^2.1.0 dev_dependencies: flutter_test: sdk: flutter - very_good_analysis: ^5.0.0+1 + very_good_analysis: ^5.1.0 screenshots: - description: Pod video player logo From 56573068a7485f73f8e9cc931673289d176ff1d0 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 02:12:33 +0300 Subject: [PATCH 07/15] added fullScreenContext --- .../pod_getx_video_controller.dart | 2 ++ lib/src/controllers/pod_video_controller.dart | 5 +-- lib/src/pod_player.dart | 4 +++ .../core/overlays/mobile_bottomsheet.dart | 6 ++-- .../widgets/core/overlays/mobile_overlay.dart | 7 +++- lib/src/widgets/core/overlays/overlays.dart | 4 ++- lib/src/widgets/core/pod_core_player.dart | 34 ++++++++++++------- lib/src/widgets/full_screen_view.dart | 6 +++- 8 files changed, 48 insertions(+), 20 deletions(-) diff --git a/lib/src/controllers/pod_getx_video_controller.dart b/lib/src/controllers/pod_getx_video_controller.dart index cb1367c5..6a3ec5a9 100644 --- a/lib/src/controllers/pod_getx_video_controller.dart +++ b/lib/src/controllers/pod_getx_video_controller.dart @@ -19,6 +19,8 @@ part 'pod_video_controller.dart'; part 'pod_video_quality_controller.dart'; class PodGetXVideoController extends _PodGesturesController { + + ///main videoplayer controller VideoPlayerController? get videoCtr => _videoCtr; diff --git a/lib/src/controllers/pod_video_controller.dart b/lib/src/controllers/pod_video_controller.dart index c827bef6..cc79ea90 100644 --- a/lib/src/controllers/pod_video_controller.dart +++ b/lib/src/controllers/pod_video_controller.dart @@ -179,7 +179,7 @@ class _PodVideoController extends _PodUiController { ]); } - _enableFullScreenView(tag, context); + _enableFullScreenView(tag, context ?? fullScreenContext); isFullScreen = true; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { update(['full-screen']); @@ -235,11 +235,12 @@ class _PodVideoController extends _PodUiController { podLog('full-screen-enabled'); Navigator.push( - context ?? mainContext, + context ?? fullScreenContext, PageRouteBuilder( fullscreenDialog: true, pageBuilder: (BuildContext context, _, __) => FullScreenView( tag: tag, + fullScreenContext: context, ), reverseTransitionDuration: const Duration(milliseconds: 400), transitionsBuilder: (context, animation, secondaryAnimation, child) => diff --git a/lib/src/pod_player.dart b/lib/src/pod_player.dart index 82f451f8..4694c0be 100644 --- a/lib/src/pod_player.dart +++ b/lib/src/pod_player.dart @@ -44,6 +44,7 @@ class PodVideoPlayer extends StatefulWidget { final Widget? videoTitle; final Color? backgroundColor; final DecorationImage? videoThumbnail; + final ValueGetter? fullScreenContext; /// Optional callback, fired when full screen mode toggles. /// @@ -72,6 +73,7 @@ class PodVideoPlayer extends StatefulWidget { this.videoThumbnail, this.onToggleFullScreen, this.onLoading, + this.fullScreenContext, }) { addToUiController(); } @@ -256,6 +258,7 @@ class _PodVideoPlayerState extends State videoPlayerCtr: podCtr.videoCtr!, videoAspectRatio: videoAspectRatio, tag: widget.controller.getTag, + fullScreenContext: widget.fullScreenContext?.call(), ); }, ); @@ -264,6 +267,7 @@ class _PodVideoPlayerState extends State videoPlayerCtr: _podCtr.videoCtr!, videoAspectRatio: videoAspectRatio, tag: widget.controller.getTag, + fullScreenContext: widget.fullScreenContext?.call(), ); } } diff --git a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart index de924b1b..03d5ae55 100644 --- a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart +++ b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart @@ -180,9 +180,11 @@ class _VideoPlaybackSelectorMob extends StatelessWidget { class _MobileOverlayBottomControlles extends StatelessWidget { final String tag; + final BuildContext? fullScreenContext; const _MobileOverlayBottomControlles({ required this.tag, + required this.fullScreenContext, }); @override @@ -231,9 +233,9 @@ class _MobileOverlayBottomControlles extends StatelessWidget { onPressed: () { if (podCtr.isOverlayVisible) { if (podCtr.isFullScreen) { - podCtr.disableFullScreen(context, tag); + podCtr.disableFullScreen(fullScreenContext ?? context, tag); } else { - podCtr.enableFullScreen(tag, context); + podCtr.enableFullScreen(tag, fullScreenContext ?? context); } } else { podCtr.toggleVideoOverlay(); diff --git a/lib/src/widgets/core/overlays/mobile_overlay.dart b/lib/src/widgets/core/overlays/mobile_overlay.dart index 1afe558d..853b9a53 100644 --- a/lib/src/widgets/core/overlays/mobile_overlay.dart +++ b/lib/src/widgets/core/overlays/mobile_overlay.dart @@ -2,9 +2,11 @@ part of 'package:pod_player/src/pod_player.dart'; class _MobileOverlay extends StatelessWidget { final String tag; + final BuildContext? fullScreenContext; const _MobileOverlay({ required this.tag, + required this.fullScreenContext, }); @override @@ -80,7 +82,10 @@ class _MobileOverlay extends StatelessWidget { ), Align( alignment: Alignment.bottomLeft, - child: _MobileOverlayBottomControlles(tag: tag), + child: _MobileOverlayBottomControlles( + tag: tag, + fullScreenContext: fullScreenContext, + ), ), ], ); diff --git a/lib/src/widgets/core/overlays/overlays.dart b/lib/src/widgets/core/overlays/overlays.dart index d634c609..f8062e28 100644 --- a/lib/src/widgets/core/overlays/overlays.dart +++ b/lib/src/widgets/core/overlays/overlays.dart @@ -2,9 +2,11 @@ part of 'package:pod_player/src/pod_player.dart'; class _VideoOverlays extends StatelessWidget { final String tag; + final BuildContext? fullScreenContext; const _VideoOverlays({ required this.tag, + required this.fullScreenContext, }); @override @@ -52,7 +54,7 @@ class _VideoOverlays extends StatelessWidget { child: Stack( fit: StackFit.passthrough, children: [ - if (!kIsWeb) _MobileOverlay(tag: tag), + if (!kIsWeb) _MobileOverlay(tag: tag, fullScreenContext: fullScreenContext,), if (kIsWeb) _WebOverlay(tag: tag), ], ), diff --git a/lib/src/widgets/core/pod_core_player.dart b/lib/src/widgets/core/pod_core_player.dart index 847a27b7..22d286ee 100644 --- a/lib/src/widgets/core/pod_core_player.dart +++ b/lib/src/widgets/core/pod_core_player.dart @@ -4,11 +4,13 @@ class _PodCoreVideoPlayer extends StatelessWidget { final VideoPlayerController videoPlayerCtr; final double videoAspectRatio; final String tag; + final BuildContext? fullScreenContext; const _PodCoreVideoPlayer({ required this.videoPlayerCtr, required this.videoAspectRatio, required this.tag, + required this.fullScreenContext, }); @override @@ -18,7 +20,9 @@ class _PodCoreVideoPlayer extends StatelessWidget { builder: (ctrx) { return RawKeyboardListener( autofocus: true, - focusNode: (podCtr.isFullScreen ? FocusNode() : podCtr.keyboardFocusWeb) ?? FocusNode(), + focusNode: + (podCtr.isFullScreen ? FocusNode() : podCtr.keyboardFocusWeb) ?? + FocusNode(), onKey: (value) => podCtr.onKeyBoardEvents( event: value, appContext: ctrx, @@ -66,7 +70,10 @@ class _PodCoreVideoPlayer extends StatelessWidget { }, ), ), - _VideoOverlays(tag: tag), + _VideoOverlays( + tag: tag, + fullScreenContext: fullScreenContext, + ), IgnorePointer( child: GetBuilder( tag: tag, @@ -130,17 +137,18 @@ class _PodCoreVideoPlayer extends StatelessWidget { : GetBuilder( tag: tag, id: 'overlay', - builder: (podCtr) => - podCtr.isOverlayVisible || !podCtr.alwaysShowProgressBar - ? const SizedBox() - : Align( - alignment: Alignment.bottomCenter, - child: PodProgressBar( - tag: tag, - alignment: Alignment.bottomCenter, - podProgressBarConfig: podCtr.podProgressBarConfig, - ), - ), + builder: (podCtr) => podCtr.isOverlayVisible || + !podCtr.alwaysShowProgressBar + ? const SizedBox() + : Align( + alignment: Alignment.bottomCenter, + child: PodProgressBar( + tag: tag, + alignment: Alignment.bottomCenter, + podProgressBarConfig: + podCtr.podProgressBarConfig, + ), + ), ), ), ], diff --git a/lib/src/widgets/full_screen_view.dart b/lib/src/widgets/full_screen_view.dart index d7b77651..c589d56b 100644 --- a/lib/src/widgets/full_screen_view.dart +++ b/lib/src/widgets/full_screen_view.dart @@ -2,8 +2,11 @@ part of 'package:pod_player/src/pod_player.dart'; class FullScreenView extends StatefulWidget { final String tag; + final BuildContext? fullScreenContext; + const FullScreenView({ required this.tag, + required this.fullScreenContext, super.key, }); @@ -17,7 +20,7 @@ class _FullScreenViewState extends State @override void initState() { _podCtr = Get.find(tag: widget.tag); - _podCtr.fullScreenContext = context; + _podCtr.fullScreenContext = widget.fullScreenContext ?? context; _podCtr.keyboardFocusWeb?.removeListener(_podCtr.keyboadListner); super.initState(); @@ -69,6 +72,7 @@ class _FullScreenViewState extends State videoPlayerCtr: podCtr.videoCtr!, videoAspectRatio: podCtr.videoCtr?.value.aspectRatio ?? 16 / 9, + fullScreenContext: widget.fullScreenContext, ) : loadingWidget, ), From 4554e06c941de734979168b412d6c9ca50534063 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 02:24:32 +0300 Subject: [PATCH 08/15] context fix --- lib/src/controllers/pod_player_controller.dart | 5 +++-- lib/src/controllers/pod_video_controller.dart | 6 +++--- .../widgets/core/overlays/mobile_bottomsheet.dart | 13 +++++++++---- lib/src/widgets/full_screen_view.dart | 6 ++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/src/controllers/pod_player_controller.dart b/lib/src/controllers/pod_player_controller.dart index 08b9667d..57558776 100644 --- a/lib/src/controllers/pod_player_controller.dart +++ b/lib/src/controllers/pod_player_controller.dart @@ -213,7 +213,8 @@ class PodPlayerController { ); //Change double tap duration - void setDoubeTapForwarDuration(int seconds) => _ctr.doubleTapForwardSeconds = seconds; + void setDoubeTapForwarDuration(int seconds) => + _ctr.doubleTapForwardSeconds = seconds; ///Jumps to specific position of the video Future videoSeekTo(Duration moment) async { @@ -263,7 +264,7 @@ class PodPlayerController { /// /// If onToggleFullScreen is set, you must handle the device /// orientation by yourself. - void disableFullScreen(BuildContext context) { + void disableFullScreen(BuildContext? context) { uni_html.document.exitFullscreen(); if (!_ctr.isWebPopupOverlayOpen) { diff --git a/lib/src/controllers/pod_video_controller.dart b/lib/src/controllers/pod_video_controller.dart index cc79ea90..377e7705 100644 --- a/lib/src/controllers/pod_video_controller.dart +++ b/lib/src/controllers/pod_video_controller.dart @@ -189,7 +189,7 @@ class _PodVideoController extends _PodUiController { } Future disableFullScreen( - BuildContext context, + BuildContext? context, String tag, { bool enablePop = true, }) async { @@ -222,9 +222,9 @@ class _PodVideoController extends _PodUiController { } } - void _exitFullScreenView(BuildContext context, String tag) { + void _exitFullScreenView(BuildContext? context, String tag) { podLog('popped-full-screen'); - Navigator.of(fullScreenContext).pop(); + Navigator.of(context ?? fullScreenContext).pop(); } void _enableFullScreenView( diff --git a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart index 03d5ae55..6c5fa0ae 100644 --- a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart +++ b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart @@ -228,21 +228,26 @@ class _MobileOverlayBottomControlles extends StatelessWidget { toolTipMesg: podCtr.isFullScreen ? podCtr.podPlayerLabels.exitFullScreen ?? 'Exit full screen${kIsWeb ? ' (f)' : ''}' - : podCtr.podPlayerLabels.fullscreen ?? 'Fullscreen${kIsWeb ? ' (f)' : ''}', + : podCtr.podPlayerLabels.fullscreen ?? + 'Fullscreen${kIsWeb ? ' (f)' : ''}', color: itemColor, onPressed: () { if (podCtr.isOverlayVisible) { if (podCtr.isFullScreen) { - podCtr.disableFullScreen(fullScreenContext ?? context, tag); + podCtr.disableFullScreen( + fullScreenContext ?? context, tag); } else { - podCtr.enableFullScreen(tag, fullScreenContext ?? context); + podCtr.enableFullScreen( + tag, fullScreenContext ?? context); } } else { podCtr.toggleVideoOverlay(); } }, child: Icon( - podCtr.isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen, + podCtr.isFullScreen + ? Icons.fullscreen_exit + : Icons.fullscreen, ), ), ], diff --git a/lib/src/widgets/full_screen_view.dart b/lib/src/widgets/full_screen_view.dart index c589d56b..b0a836b3 100644 --- a/lib/src/widgets/full_screen_view.dart +++ b/lib/src/widgets/full_screen_view.dart @@ -46,12 +46,14 @@ class _FullScreenViewState extends State onPopInvoked: (_) async { if (kIsWeb) { await _podCtr.disableFullScreen( - context, + widget.fullScreenContext ?? context, widget.tag, enablePop: false, ); } - if (!kIsWeb) await _podCtr.disableFullScreen(context, widget.tag); + if (!kIsWeb) + await _podCtr.disableFullScreen( + widget.fullScreenContext ?? context, widget.tag); }, child: Scaffold( backgroundColor: Colors.black, From 20c0ff4db2ea7dfad445bc873199ba3d05f26fe4 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 02:33:39 +0300 Subject: [PATCH 09/15] refactoring --- lib/src/widgets/full_screen_view.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/src/widgets/full_screen_view.dart b/lib/src/widgets/full_screen_view.dart index b0a836b3..c589d56b 100644 --- a/lib/src/widgets/full_screen_view.dart +++ b/lib/src/widgets/full_screen_view.dart @@ -46,14 +46,12 @@ class _FullScreenViewState extends State onPopInvoked: (_) async { if (kIsWeb) { await _podCtr.disableFullScreen( - widget.fullScreenContext ?? context, + context, widget.tag, enablePop: false, ); } - if (!kIsWeb) - await _podCtr.disableFullScreen( - widget.fullScreenContext ?? context, widget.tag); + if (!kIsWeb) await _podCtr.disableFullScreen(context, widget.tag); }, child: Scaffold( backgroundColor: Colors.black, From 9b8a4d4d439f43d08b56e1c886bb198e62dc8822 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 02:36:04 +0300 Subject: [PATCH 10/15] ref --- lib/src/widgets/core/overlays/mobile_bottomsheet.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart index 6c5fa0ae..4efc9518 100644 --- a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart +++ b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart @@ -234,8 +234,7 @@ class _MobileOverlayBottomControlles extends StatelessWidget { onPressed: () { if (podCtr.isOverlayVisible) { if (podCtr.isFullScreen) { - podCtr.disableFullScreen( - fullScreenContext ?? context, tag); + podCtr.disableFullScreen(context, tag); } else { podCtr.enableFullScreen( tag, fullScreenContext ?? context); From 333507c67c001095312b47fa08ca5fbfec5fc42e Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 02:47:23 +0300 Subject: [PATCH 11/15] refacgtoring --- lib/src/widgets/core/overlays/mobile_bottomsheet.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart index 4efc9518..6c5fa0ae 100644 --- a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart +++ b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart @@ -234,7 +234,8 @@ class _MobileOverlayBottomControlles extends StatelessWidget { onPressed: () { if (podCtr.isOverlayVisible) { if (podCtr.isFullScreen) { - podCtr.disableFullScreen(context, tag); + podCtr.disableFullScreen( + fullScreenContext ?? context, tag); } else { podCtr.enableFullScreen( tag, fullScreenContext ?? context); From 624630a59063a82e0a4293ae5ffde2cfcb9c63ff Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 11:05:45 +0300 Subject: [PATCH 12/15] ref --- lib/src/widgets/core/overlays/mobile_bottomsheet.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart index 6c5fa0ae..6e26e884 100644 --- a/lib/src/widgets/core/overlays/mobile_bottomsheet.dart +++ b/lib/src/widgets/core/overlays/mobile_bottomsheet.dart @@ -235,7 +235,9 @@ class _MobileOverlayBottomControlles extends StatelessWidget { if (podCtr.isOverlayVisible) { if (podCtr.isFullScreen) { podCtr.disableFullScreen( - fullScreenContext ?? context, tag); + context, + tag, + ); } else { podCtr.enableFullScreen( tag, fullScreenContext ?? context); From 3ce5a9377805645618a89c940b93dfd9bb88f76a Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 11:21:39 +0300 Subject: [PATCH 13/15] ref --- lib/src/controllers/pod_video_controller.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/controllers/pod_video_controller.dart b/lib/src/controllers/pod_video_controller.dart index 377e7705..a410e579 100644 --- a/lib/src/controllers/pod_video_controller.dart +++ b/lib/src/controllers/pod_video_controller.dart @@ -224,7 +224,7 @@ class _PodVideoController extends _PodUiController { void _exitFullScreenView(BuildContext? context, String tag) { podLog('popped-full-screen'); - Navigator.of(context ?? fullScreenContext).pop(); + Navigator.of(fullScreenContext).pop(); } void _enableFullScreenView( @@ -233,7 +233,6 @@ class _PodVideoController extends _PodUiController { ) { if (!isFullScreen) { podLog('full-screen-enabled'); - Navigator.push( context ?? fullScreenContext, PageRouteBuilder( From a6bbc8f6f58f96b90022cb9f0a3f25a636ac165b Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 11:27:48 +0300 Subject: [PATCH 14/15] ref --- lib/src/controllers/pod_video_controller.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/controllers/pod_video_controller.dart b/lib/src/controllers/pod_video_controller.dart index a410e579..95c9dd15 100644 --- a/lib/src/controllers/pod_video_controller.dart +++ b/lib/src/controllers/pod_video_controller.dart @@ -224,7 +224,9 @@ class _PodVideoController extends _PodUiController { void _exitFullScreenView(BuildContext? context, String tag) { podLog('popped-full-screen'); - Navigator.of(fullScreenContext).pop(); + if (Navigator.of(fullScreenContext).canPop()) { + Navigator.of(fullScreenContext).pop(); + } } void _enableFullScreenView( From 221ac728032b2cbd8c49e693fbbeef26249567e5 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Fri, 9 Feb 2024 12:00:12 +0300 Subject: [PATCH 15/15] added safeArea --- lib/src/widgets/full_screen_view.dart | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/src/widgets/full_screen_view.dart b/lib/src/widgets/full_screen_view.dart index c589d56b..5d137786 100644 --- a/lib/src/widgets/full_screen_view.dart +++ b/lib/src/widgets/full_screen_view.dart @@ -55,26 +55,29 @@ class _FullScreenViewState extends State }, child: Scaffold( backgroundColor: Colors.black, - body: GetBuilder( - tag: widget.tag, - builder: (podCtr) => Center( - child: ColoredBox( - color: Colors.black, - child: SizedBox( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - child: Center( - child: podCtr.videoCtr == null - ? loadingWidget - : podCtr.videoCtr!.value.isInitialized - ? _PodCoreVideoPlayer( - tag: widget.tag, - videoPlayerCtr: podCtr.videoCtr!, - videoAspectRatio: - podCtr.videoCtr?.value.aspectRatio ?? 16 / 9, - fullScreenContext: widget.fullScreenContext, - ) - : loadingWidget, + body: SafeArea( + child: GetBuilder( + tag: widget.tag, + builder: (podCtr) => Center( + child: ColoredBox( + color: Colors.black, + child: SizedBox( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + child: Center( + child: podCtr.videoCtr == null + ? loadingWidget + : podCtr.videoCtr!.value.isInitialized + ? _PodCoreVideoPlayer( + tag: widget.tag, + videoPlayerCtr: podCtr.videoCtr!, + videoAspectRatio: + podCtr.videoCtr?.value.aspectRatio ?? + 16 / 9, + fullScreenContext: widget.fullScreenContext, + ) + : loadingWidget, + ), ), ), ),