i am trying to make video player look like but i am having trouble finding work around for this i need some directions what to do as how to make the video duration accessible outside the videoplayer in a text widget
Getting duration of video outside the videoplayer widget
Custom Code
gemini prompt for state management and custom actions that i didn't fully understand
custom chewie videoplayer that works
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/actions/actions.dart' as action_blocks;
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:chewie/chewie.dart';
import 'package:intl/intl.dart';
import 'package:video_player/video_player.dart';
class FlickVideoPlayer extends StatefulWidget {
final String videoUrl;
final DateTime date;
final double? width;
final double? height;
const FlickVideoPlayer({
Key? key,
required this.videoUrl,
required this.date,
this.width,
this.height,
}) : super(key: key);
@override
_FlickVideoPlayerState createState() => _FlickVideoPlayerState();
}
class _FlickVideoPlayerState extends State<FlickVideoPlayer> {
late VideoPlayerController _videoPlayerController;
ChewieController? _chewieController;
@override
void initState() {
super.initState();
initializePlayer();
}
Future<void> initializePlayer() async {
_videoPlayerController =
VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl));
await _videoPlayerController.initialize();
_chewieController = ChewieController(
videoPlayerController: _videoPlayerController,
autoPlay: false,
looping: false,
aspectRatio: 16 / 9,
placeholder: Center(child: CircularProgressIndicator()),
);
setState(() {});
}
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: widget.width,
height: widget.height,
child: Card(
clipBehavior: Clip.antiAlias,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (_chewieController != null &&
_videoPlayerController.value.isInitialized)
AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: Chewie(controller: _chewieController!),
)
else
AspectRatio(
aspectRatio: 16 / 9,
child: Center(child: CircularProgressIndicator()),
),
],
),
),
);
}
}
Yes
2
1 reply