fluttercommunity / fluttercommunity/chewie
unable to click controls
- Dominant language
- Dart
- Stars
- 2.1k
- Forks
- 1.1k
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 6
Description
I copy example and try to do some modify, however I notice that the player controls unable to click / seek
`video_player: ^2.4.5`
`chewie: ^1.3.4`
https://user-images.githubusercontent.com/6957533/177092594-8349ca0e-eb49-4cd4-b4ba-1d1db7fc76da.mp4
```
import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class VideoView extends StatefulWidget {
const VideoView({
Key? key,
}) : super(key: key);
@override
State createState() {
return _VideoViewState();
}
}
class _VideoViewState extends State {
late VideoPlayerController _videoPlayerController;
ChewieController? _chewieController;
int? bufferDelay;
@override
void initState() {
super.initState();
initializePlayer();
}
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController?.dispose();
super.dispose();
}
List srcs = [
"https://assets.mixkit.co/videos/preview/mixkit-spinning-around-the-earth-29351-large.mp4",
"https://assets.mixkit.co/videos/preview/mixkit-daytime-city-traffic-aerial-view-56-large.mp4",
"https://assets.mixkit.co/videos/preview/mixkit-a-girl-blowing-a-bubble-gum-at-an-amusement-park-1226-large.mp4"
];
Future initializePlayer() async {
_videoPlayerController = VideoPlayerController.network(srcs[currPlayIndex]);
await Future.wait([
_videoPlayerController.initialize(),
]);
_createChewieController();
setState(() {});
}
void _createChewieController() {
_chewieController = ChewieController(
videoPlayerController: _videoPlayerController,
autoPlay: true,
looping: true,
progressIndicatorDelay: Duration(seconds: 1),
additionalOptions: (context) {
return [
OptionItem(
onTap: toggleVideo,
iconData: Icons.live_tv_sharp,
title: 'Toggle Video Src',
),
];
},
customControls: MaterialControls(
showPlayButton: true,
),
hideControlsTimer: const Duration(seconds: 3),
// materialProgressColors: ChewieProgressColors(
// playedColor: Colors.red,
// handleColor: Colors.blue,
// backgroundColor: Colors.grey,
// bufferedColor: Colors.lightGreen,
// ),
// placeholder: Container(
// color: Colors.grey,
// ),
// autoInitialize: true,
);
}
int currPlayIndex = 0;
Future toggleVideo() async {
await _videoPlayerController.pause();
currPlayIndex += 1;
if (currPlayIndex >= srcs.length) {
currPlayIndex = 0;
}
await initializePlayer();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
colorScheme: const ColorScheme.light(secondary: Colors.red),
disabledColor: Colors.grey.shade400,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
leading: IconButton(
splashRadius: 10.sp,
icon: Container(
height: kToolbarHeight,
width: kToolbarHeight,
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(100)
),
child: Icon(Icons.arrow_back_rounded, color: Colors.white, size: 22.sp)
),
onPressed: (){
Navigator.pop(context);
},
),
),
extendBody: true,
extendBodyBehindAppBar: true,
body: Column(
children: [
Expanded(
child: Center(
child: _chewieController != null && _chewieController!.videoPlayerController.value.isInitialized ?
Chewie(
controller: _chewieController!,
)
:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
CircularProgressIndicator(),
SizedBox(height: 20),
Text('Loading'),
],
),
),
),
SizedBox(height: 100.sp,)
],
),
),
);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.