From d3c603e962028a6cee87e1c640f7b3be4d569d3f Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 2 Oct 2021 14:43:41 +0530 Subject: [PATCH] old copy --- CHANGELOG.md | 5 + lib/myPlayer.dart | 4 +- lib/playerStyles/basicPlayerStyle.dart | 328 +++++++++++----------- lib/playerStyles/mxPlayerStyle.dart | 2 +- lib/provider/playerFunctionsProvider.dart | 4 +- lib/qplayer.dart | 13 +- pubspec.lock | 8 +- pubspec.yaml | 2 +- 8 files changed, 186 insertions(+), 180 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2541eb4..f8157b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.0.5] - 19/12/2020. + +* fix initialized error + + ## [0.0.4] - 19/12/2020. * update basic plugins. diff --git a/lib/myPlayer.dart b/lib/myPlayer.dart index fb78990..d8142eb 100644 --- a/lib/myPlayer.dart +++ b/lib/myPlayer.dart @@ -34,15 +34,17 @@ class _MyPlayerState extends State with WidgetsBindingObserver{ child: Stack( children: [ if (playerProvider.videoPlayerController != null && - playerProvider.videoPlayerController.value.initialized) + playerProvider.videoPlayerController.value.isInitialized) Center( child: AspectRatio( aspectRatio: playerFunctionsProvider.aspectRatioVal, child: VideoPlayer(playerProvider.videoPlayerController), ), ), + if (playerProvider.videoPlayerController != null) playerStyleSelector(), + if (playerProvider.videoPlayerController == null && playerProvider.videoThumbnail != null) Center(child: Image.network(playerProvider.videoThumbnail)), diff --git a/lib/playerStyles/basicPlayerStyle.dart b/lib/playerStyles/basicPlayerStyle.dart index fae44c2..38f1e48 100644 --- a/lib/playerStyles/basicPlayerStyle.dart +++ b/lib/playerStyles/basicPlayerStyle.dart @@ -17,178 +17,178 @@ class _BasicPlayerStyleState extends State { Widget build(BuildContext context) { _playerProvider = Provider.of(context); _playerFunctionsProvider = Provider.of(context); - return !_playerProvider.videoPlayerController.value.initialized + return !_playerProvider.videoPlayerController.value.isInitialized ? CircularProgressIndicator( - valueColor: - AlwaysStoppedAnimation(_playerProvider.loadingColor), - ) + valueColor: + AlwaysStoppedAnimation(_playerProvider.loadingColor), + ) : Stack( - children: [ - Positioned( - top: 0, - bottom: 0, - left: 0, - right: 0, - child: GestureDetector( - onTap: () { - _playerFunctionsProvider.setFunctionVisibility(); - }, - onDoubleTapDown: (val) { - _playerFunctionsProvider.doubleTapVideoSeek( - context: context, localPosition: val.localPosition); - }, - onDoubleTap: () {}, - child: Container( - color: Colors.transparent, - ), - ), - ), - if (_playerFunctionsProvider.functionVisibility) - Positioned( - bottom: 20, - left: 0, - right: 0, - child: Container( - height: 70, - child: Column( - children: [ - Stack( - children: [ - SliderTheme( - data: SliderThemeData( - thumbShape: SliderComponentShape.noThumb, - ), - child: Slider( - onChanged: (val) {}, - value: _playerFunctionsProvider - .videoBuffered.end.inMilliseconds - .toDouble(), - max: - _playerFunctionsProvider.getVideoDuration(), - min: _playerFunctionsProvider - .videoBuffered.start.inMilliseconds - .toDouble(), - activeColor: _playerProvider.progressColor - .withOpacity(.4), - ), - ), - Slider( - onChanged: (double value) { - _playerFunctionsProvider - .seekVideoPosition(value); - }, - value: _playerFunctionsProvider - .currentVideoPosition(), - min: 0, - max: _playerFunctionsProvider.getVideoDuration(), - activeColor: _playerProvider.progressColor, - inactiveColor: - _playerProvider.progressColor.withOpacity(.2), - ), - ], + children: [ + Positioned( + top: 0, + bottom: 0, + left: 0, + right: 0, + child: GestureDetector( + onTap: () { + _playerFunctionsProvider.setFunctionVisibility(); + }, + onDoubleTapDown: (val) { + _playerFunctionsProvider.doubleTapVideoSeek( + context: context, localPosition: val.localPosition); + }, + onDoubleTap: () {}, + child: Container( + color: Colors.transparent, ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 25), - child: Row( + ), + ), + if (_playerFunctionsProvider.functionVisibility) + Positioned( + bottom: 20, + left: 0, + right: 0, + child: Container( + height: 70, + child: Column( children: [ - Text( - ConvertOperations().convertToDisplayTimeFormat( - _playerFunctionsProvider - .currentVideoPosition()), - style: TextStyle(color: Colors.white), - ), - Text( - "/", - style: TextStyle(color: Colors.white), - ), - Text( - ConvertOperations().convertToDisplayTimeFormat( - _playerFunctionsProvider - .getVideoDuration()), - style: TextStyle(color: Colors.white), - ), - InkWell( - onTap: () { - _playerFunctionsProvider - .muteAndUnMuteFunction(getStatus: false); - }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 8), - child: Icon( - _playerFunctionsProvider - .muteAndUnMuteFunction( - getStatus: true) - ? Icons.volume_up - : Icons.volume_off, - color: Colors.white, - size: 20, + Stack( + children: [ + SliderTheme( + data: SliderThemeData( + thumbShape: SliderComponentShape.noThumb, + ), + child: Slider( + onChanged: (val) {}, + value: _playerFunctionsProvider + .videoBuffered.end.inMilliseconds + .toDouble(), + max: + _playerFunctionsProvider.getVideoDuration(), + min: _playerFunctionsProvider + .videoBuffered.start.inMilliseconds + .toDouble(), + activeColor: _playerProvider.progressColor + .withOpacity(.4), + ), ), - ), - ), - Expanded( - child: Container(), - ), - Text( - "-", - style: TextStyle(color: Colors.white), - ), - Text( - ConvertOperations().remainingTime( - endTime: _playerFunctionsProvider - .getVideoDuration(), - startTime: _playerFunctionsProvider - .currentVideoPosition(), - ), - style: TextStyle(color: Colors.white), + Slider( + onChanged: (double value) { + _playerFunctionsProvider + .seekVideoPosition(value); + }, + value: _playerFunctionsProvider + .currentVideoPosition(), + min: 0, + max: _playerFunctionsProvider.getVideoDuration(), + activeColor: _playerProvider.progressColor, + inactiveColor: + _playerProvider.progressColor.withOpacity(.2), + ), + ], ), - SizedBox(width: 16), - InkWell( - onTap: () { - _playerFunctionsProvider - .switchAspectRatio(context); - }, - child: Icon( - Icons.aspect_ratio, - color: Colors.white, - size: 20, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 25), + child: Row( + children: [ + Text( + ConvertOperations().convertToDisplayTimeFormat( + _playerFunctionsProvider + .currentVideoPosition()), + style: TextStyle(color: Colors.white), + ), + Text( + "/", + style: TextStyle(color: Colors.white), + ), + Text( + ConvertOperations().convertToDisplayTimeFormat( + _playerFunctionsProvider + .getVideoDuration()), + style: TextStyle(color: Colors.white), + ), + InkWell( + onTap: () { + _playerFunctionsProvider + .muteAndUnMuteFunction(getStatus: false); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Icon( + _playerFunctionsProvider + .muteAndUnMuteFunction( + getStatus: true) + ? Icons.volume_up + : Icons.volume_off, + color: Colors.white, + size: 20, + ), + ), + ), + Expanded( + child: Container(), + ), + Text( + "-", + style: TextStyle(color: Colors.white), + ), + Text( + ConvertOperations().remainingTime( + endTime: _playerFunctionsProvider + .getVideoDuration(), + startTime: _playerFunctionsProvider + .currentVideoPosition(), + ), + style: TextStyle(color: Colors.white), + ), + SizedBox(width: 16), + InkWell( + onTap: () { + _playerFunctionsProvider + .switchAspectRatio(context); + }, + child: Icon( + Icons.aspect_ratio, + color: Colors.white, + size: 20, + ), + ), + ], ), - ), + ) ], ), - ) - ], - ), - ), - ), - if (_playerProvider.videoTitle != null && - _playerFunctionsProvider.functionVisibility) - Positioned( - top: 0, - left: 0, - right: 0, - child: Container( - child: AppBar( - backgroundColor: Colors.black26, - titleSpacing: 0, - elevation: 0, - title: Text('${_playerProvider.videoTitle}'), - ), - ), - ), - if (_playerFunctionsProvider.functionVisibility) - Center( - child: IconButton( - onPressed: () { - _playerFunctionsProvider.playControl(); - }, - icon: Icon( - _playerFunctionsProvider.playControlIcon, - size: 50, - color: _playerProvider.iconsColor, - ), - ), - ), - ], - ); + ), + ), + if (_playerProvider.videoTitle != null && + _playerFunctionsProvider.functionVisibility) + Positioned( + top: 0, + left: 0, + right: 0, + child: Container( + child: AppBar( + backgroundColor: Colors.black26, + titleSpacing: 0, + elevation: 0, + title: Text('${_playerProvider.videoTitle}'), + ), + ), + ), + if (_playerFunctionsProvider.functionVisibility) + Center( + child: IconButton( + onPressed: () { + _playerFunctionsProvider.playControl(); + }, + icon: Icon( + _playerFunctionsProvider.playControlIcon, + size: 50, + color: _playerProvider.iconsColor, + ), + ), + ), + ], + ); } } diff --git a/lib/playerStyles/mxPlayerStyle.dart b/lib/playerStyles/mxPlayerStyle.dart index 5b99b3b..61bc54d 100644 --- a/lib/playerStyles/mxPlayerStyle.dart +++ b/lib/playerStyles/mxPlayerStyle.dart @@ -21,7 +21,7 @@ class _MxPlayerStyleState extends State { Size size = MediaQuery.of(context).size; return WillPopScope( onWillPop: _backPressCtrl, - child: !playerPro.videoPlayerController.value.initialized?CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(playerPro.loadingColor),):Stack( + child: !playerPro.videoPlayerController.value.isInitialized?CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(playerPro.loadingColor),):Stack( children: [ Positioned( top: 0, diff --git a/lib/provider/playerFunctionsProvider.dart b/lib/provider/playerFunctionsProvider.dart index 35deb28..9c02e5d 100644 --- a/lib/provider/playerFunctionsProvider.dart +++ b/lib/provider/playerFunctionsProvider.dart @@ -68,7 +68,7 @@ class PlayerFunctionsProvider extends ChangeNotifier { double getVideoDuration() { int videoDuration = 1; - if (playerProvider.videoPlayerController.value.initialized && + if (playerProvider.videoPlayerController.value.isInitialized && playerProvider.videoPlayerController.value != null) { videoDuration = playerProvider.videoPlayerController.value.duration.inMilliseconds; @@ -78,7 +78,7 @@ class PlayerFunctionsProvider extends ChangeNotifier { double currentVideoPosition() { int videoPosition = 0; - if (playerProvider.videoPlayerController.value.initialized && + if (playerProvider.videoPlayerController.value.isInitialized && playerProvider.videoPlayerController.value != null) { videoPosition = playerProvider.videoPlayerController.value.position.inMilliseconds; diff --git a/lib/qplayer.dart b/lib/qplayer.dart index c1c0852..99f26b3 100644 --- a/lib/qplayer.dart +++ b/lib/qplayer.dart @@ -32,6 +32,7 @@ class QPlayer extends StatefulWidget { final Duration quickFastDuration; final Duration startingPosition; final ValueChanged getVideoPlayerController; + const QPlayer({ Key key, @required this.videoUrl, @@ -48,7 +49,6 @@ class QPlayer extends StatefulWidget { this.functionKeyVisibleTime = const Duration(seconds: 2), this.quickFastDuration = const Duration(seconds: 2), this.startingPosition = const Duration(), - this.getVideoPlayerController, }) : super(key: key); @@ -73,7 +73,6 @@ class _QPlayerState extends State { ); } - @override void initState() { super.initState(); @@ -97,16 +96,16 @@ class _QPlayerState extends State { loadingColor: widget.loadingColor, quickFastDuration: widget.quickFastDuration, startingPosition: widget.startingPosition, - ); }); - if(widget.getVideoPlayerController != null){ + if (widget.getVideoPlayerController != null) { Timer.periodic(Duration(seconds: 1), (timer) { - if(playerProvider.videoPlayerController != null){ - if(!mounted)return; + if (playerProvider.videoPlayerController != null) { + if (!mounted) return; setState(() { - widget.getVideoPlayerController(playerProvider.videoPlayerController); + widget + .getVideoPlayerController(playerProvider.videoPlayerController); }); timer.cancel(); } diff --git a/pubspec.lock b/pubspec.lock index e7121ee..5f0e804 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -92,7 +92,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -160,7 +160,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.2" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9765f76..b9aae2c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: qplayer description: Make an easy video player with multi in build player styles -version: 0.0.4 +version: 0.0.5 #authors: [dpon1996@gmail.com] homepage: https://github.com/dpon1996/qplayer.git