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

Remove videoTitle IgnorePointer #164

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
include: package:very_good_analysis/analysis_options.yaml
analyzer:
exclude:
- "**"
errors:
missing_required_param: error
prefer_const_declarations: warning
prefer_const_constructors: warning
import_of_legacy_library_into_null_safe: warning
public_member_api_docs: ignore
language:
strict-casts: true
Expand Down
73 changes: 29 additions & 44 deletions example/lib/screens/cutom_video_controllers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
late PodPlayerController controller;
bool? isVideoPlaying;
final videoTextFieldCtr = TextEditingController(
text:
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4',
text: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4',
);
final vimeoTextFieldCtr = TextEditingController(
text: '518228118',
Expand Down Expand Up @@ -67,22 +66,18 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
Widget build(BuildContext context) {
///
const sizeH20 = SizedBox(height: 20);
final totalHour = controller.currentVideoPosition.inHours == 0
? '0'
: '${controller.currentVideoPosition.inHours}:';
final totalMinute =
controller.currentVideoPosition.toString().split(':')[1];
final totalSeconds = (controller.currentVideoPosition -
Duration(minutes: controller.currentVideoPosition.inMinutes))
.inSeconds
.toString()
.padLeft(2, '0');
final totalHour =
controller.currentVideoPosition.inHours == 0 ? '0' : '${controller.currentVideoPosition.inHours}:';
final totalMinute = controller.currentVideoPosition.toString().split(':')[1];
final totalSeconds =
(controller.currentVideoPosition - Duration(minutes: controller.currentVideoPosition.inMinutes))
.inSeconds
.toString()
.padLeft(2, '0');

///
const videoTitle = Padding(
padding: kIsWeb
? EdgeInsets.symmetric(vertical: 25, horizontal: 15)
: EdgeInsets.only(left: 15),
padding: kIsWeb ? EdgeInsets.symmetric(vertical: 25, horizontal: 15) : EdgeInsets.only(left: 15),
child: Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
style: TextStyle(
Expand Down Expand Up @@ -149,46 +144,37 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
sizeH20,
_loadVideoFromYoutube(),
sizeH20,
_iconButton('Hide progress bar on overlay hidden',
Icons.hide_source, onPressed: () {
_iconButton('Hide progress bar on overlay hidden', Icons.hide_source, onPressed: () {
setState(() {
alwaysShowProgressBar = false;
});
}),
sizeH20,
_iconButton('Show Overlay', Icons.slideshow_outlined,
onPressed: () {
_iconButton('Show Overlay', Icons.slideshow_outlined, onPressed: () {
controller.showOverlay();
}),
sizeH20,
_iconButton('Hide Overlay', Icons.hide_image,
onPressed: () {
_iconButton('Hide Overlay', Icons.hide_image, onPressed: () {
controller.hideOverlay();
}),
_iconButton('Backward video 5s', Icons.replay_5_rounded,
onPressed: () {
_iconButton('Backward video 5s', Icons.replay_5_rounded, onPressed: () {
controller.doubleTapVideoBackward(5);
}),
sizeH20,
_iconButton('Forward video 5s', Icons.forward_5_rounded,
onPressed: () {
_iconButton('Forward video 5s', Icons.forward_5_rounded, onPressed: () {
controller.doubleTapVideoForward(5);
}),
sizeH20,
_iconButton('Video Jump to 01:00 minute',
Icons.fast_forward_rounded, onPressed: () {
_iconButton('Video Jump to 01:00 minute', Icons.fast_forward_rounded, onPressed: () {
controller.videoSeekTo(const Duration(minutes: 1));
}),
sizeH20,
_iconButton('Enable full screen', Icons.fullscreen,
onPressed: () {
_iconButton('Enable full screen', Icons.fullscreen, onPressed: () {
controller.enableFullScreen();
}),
sizeH20,
_iconButton(
controller.isMute ? 'UnMute video' : 'mute video',
controller.isMute ? Icons.volume_up : Icons.volume_off,
onPressed: () {
_iconButton(controller.isMute ? 'UnMute video' : 'mute video',
controller.isMute ? Icons.volume_up : Icons.volume_off, onPressed: () {
controller.toggleVolume();
}),
sizeH20,
Expand Down Expand Up @@ -217,16 +203,19 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
backgroundColor: Colors.black,
onPressed: () => controller.togglePlayPause(),
child: isVideoPlaying == null
? const SizedBox(
? SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
backgroundColor: Colors.black,
color: Colors.white,
color: Theme.of(context).colorScheme.primary,
strokeWidth: 1,
),
)
: Icon(!isVideoPlaying! ? Icons.play_arrow : Icons.pause),
: Icon(
!isVideoPlaying! ? Icons.play_arrow : Icons.pause,
color: Theme.of(context).colorScheme.primary,
),
),
);
}
Expand Down Expand Up @@ -267,8 +256,7 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar();
} catch (e) {
snackBar(
"Unable to load,${kIsWeb ? 'Please enable CORS in web' : ''} \n$e");
snackBar("Unable to load,${kIsWeb ? 'Please enable CORS in web' : ''} \n$e");
}
},
child: const Text('Load Video'),
Expand Down Expand Up @@ -313,8 +301,7 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar();
} catch (e) {
snackBar(
"Unable to load,${kIsWeb ? 'Please enable CORS in web' : ''} \n$e");
snackBar("Unable to load,${kIsWeb ? 'Please enable CORS in web' : ''} \n$e");
}
},
child: const Text('Load Video'),
Expand Down Expand Up @@ -372,12 +359,10 @@ class _CustomVideoControllsState extends State<CustomVideoControlls> {
);
}

ElevatedButton _iconButton(String text, IconData icon,
{void Function()? onPressed}) {
ElevatedButton _iconButton(String text, IconData icon, {void Function()? onPressed}) {
return ElevatedButton.icon(
onPressed: onPressed ?? () {},
style: ElevatedButton.styleFrom(
fixedSize: const Size.fromWidth(double.maxFinite)),
style: ElevatedButton.styleFrom(fixedSize: const Size.fromWidth(double.maxFinite)),
icon: Icon(icon),
label: Text(text));
}
Expand Down
1 change: 1 addition & 0 deletions example/lib/screens/from_youtube.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class _PlayVideoFromVimeoIdState extends State<PlayVideoFromYoutube> {
shrinkWrap: true,
children: [
PodVideoPlayer(
podProgressBarConfig: const PodProgressBarConfig(),
controller: controller,
videoThumbnail: const DecorationImage(
image: NetworkImage(
Expand Down
11 changes: 6 additions & 5 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ dependencies:
pod_player:
path: ../

cupertino_icons: ^1.0.5
visibility_detector: ^0.3.3
cupertino_icons:
visibility_detector:

dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^2.0.1
flutter_lints:

flutter:
uses-material-design: true

assets:
- assets/
- assets/

17 changes: 9 additions & 8 deletions lib/src/controllers/pod_base_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ class _PodBaseController extends GetxController {

///updates state with id `_podVideoState`
void podVideoStateChanger(PodVideoState? val, {bool updateUi = true}) {
if (_podVideoState != (val ?? _podVideoState)) {
_podVideoState = val ?? _podVideoState;
if (updateUi) {
update(['podVideoState']);
update(['update-all']);
}
// 判断前值, 会导致 player 隐藏后无法再控制播放和暂停
// if (_podVideoState != (val ?? _podVideoState)) {
_podVideoState = val ?? _podVideoState;
if (updateUi) {
// print("podVideoStateChanger val=$val _podVideoState=$_podVideoState");
update(['podVideoState']);
update(['update-all']);
}
// }
}

void _listneToVideoPosition() {
Expand All @@ -96,8 +98,7 @@ class _PodBaseController extends GetxController {
update(['video-progress']);
update(['update-all']);
} else {
if (_videoPosition.inSeconds !=
(_videoCtr?.value.position ?? Duration.zero).inSeconds) {
if (_videoPosition.inSeconds != (_videoCtr?.value.position ?? Duration.zero).inSeconds) {
_videoPosition = _videoCtr?.value.position ?? Duration.zero;
update(['video-progress']);
update(['update-all']);
Expand Down
10 changes: 3 additions & 7 deletions lib/src/controllers/pod_getx_video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -110,7 +109,6 @@ class PodGetXVideoController extends _PodGesturesController {
);
playingVideoUrl = url;

break;
case PodVideoPlayerType.youtube:
final urls = await getVideoQualityUrlsFromYoutube(
playVideoFrom.dataSource!,
Expand All @@ -131,7 +129,6 @@ class PodGetXVideoController extends _PodGesturesController {
);
playingVideoUrl = url;

break;
case PodVideoPlayerType.vimeo:
await getQualityUrlsFromVimeoId(
playVideoFrom.dataSource!,
Expand All @@ -151,7 +148,6 @@ class PodGetXVideoController extends _PodGesturesController {
);
playingVideoUrl = url;

break;
case PodVideoPlayerType.asset:

///
Expand All @@ -163,7 +159,6 @@ class PodGetXVideoController extends _PodGesturesController {
);
playingVideoUrl = playVideoFrom.dataSource;

break;
case PodVideoPlayerType.file:
if (kIsWeb) {
throw Exception('file doesnt support web');
Expand All @@ -176,7 +171,6 @@ class PodGetXVideoController extends _PodGesturesController {
videoPlayerOptions: playVideoFrom.videoPlayerOptions,
);

break;
case PodVideoPlayerType.vimeoPrivateVideos:
await getQualityUrlsFromVimeoPrivateId(
playVideoFrom.dataSource!,
Expand Down Expand Up @@ -277,7 +271,9 @@ class PodGetXVideoController extends _PodGesturesController {
///checkes wether video should be `autoplayed` initially
void checkAutoPlayVideo() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
if (autoPlay && (isVideoUiBinded ?? false)) {
// 一些奇怪的图片资源加载异常, 都会导致 isVideoUiBinded 不成功, 这里不再检查, 直接自动播放
// if (autoPlay && (isVideoUiBinded ?? false)) {
if (autoPlay) {
if (kIsWeb) await _videoCtr?.setVolume(0);
podVideoStateChanger(PodVideoState.playing);
} else {
Expand Down
7 changes: 3 additions & 4 deletions lib/src/pod_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ class PodVideoPlayer extends StatefulWidget {
State<PodVideoPlayer> createState() => _PodVideoPlayerState();
}

class _PodVideoPlayerState extends State<PodVideoPlayer>
with TickerProviderStateMixin {
class _PodVideoPlayerState extends State<PodVideoPlayer> with TickerProviderStateMixin {
late PodGetXVideoController _podCtr;

// late String tag;
Expand Down Expand Up @@ -212,9 +211,9 @@ class _PodVideoPlayerState extends State<PodVideoPlayer>

Widget _buildLoading() {
return widget.onLoading?.call(context) ??
const CircularProgressIndicator(
CircularProgressIndicator(
backgroundColor: Colors.black87,
color: Colors.white,
color: Theme.of(context).colorScheme.primary,
strokeWidth: 2,
);
}
Expand Down
15 changes: 6 additions & 9 deletions lib/src/widgets/animated_play_pause_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class _AnimatedPlayPauseIcon extends StatefulWidget {
State<_AnimatedPlayPauseIcon> createState() => _AnimatedPlayPauseIconState();
}

class _AnimatedPlayPauseIconState extends State<_AnimatedPlayPauseIcon>
with SingleTickerProviderStateMixin {
class _AnimatedPlayPauseIconState extends State<_AnimatedPlayPauseIcon> with SingleTickerProviderStateMixin {
late final AnimationController _payCtr;
late PodGetXVideoController _podCtr;
@override
Expand Down Expand Up @@ -60,12 +59,9 @@ class _AnimatedPlayPauseIconState extends State<_AnimatedPlayPauseIcon>
id: 'podVideoState',
builder: (f) => MaterialIconButton(
toolTipMesg: f.isvideoPlaying
? podCtr.podPlayerLabels.pause ??
'Pause${kIsWeb ? ' (space)' : ''}'
: podCtr.podPlayerLabels.play ??
'Play${kIsWeb ? ' (space)' : ''}',
onPressed:
podCtr.isOverlayVisible ? podCtr.togglePlayPauseVideo : null,
? podCtr.podPlayerLabels.pause ?? 'Pause${kIsWeb ? ' (space)' : ''}'
: podCtr.podPlayerLabels.play ?? 'Play${kIsWeb ? ' (space)' : ''}',
onPressed: podCtr.isOverlayVisible ? podCtr.togglePlayPauseVideo : null,
child: onStateChange(podCtr),
),
);
Expand All @@ -86,7 +82,8 @@ class _AnimatedPlayPauseIconState extends State<_AnimatedPlayPauseIcon>
return AnimatedIcon(
icon: AnimatedIcons.play_pause,
progress: _payCtr,
color: Colors.white,
// 操作按钮的颜色
color: Theme.of(context).colorScheme.primary,
size: widget.size,
);
}
Expand Down
Loading