Hello, I made custom controls on the video player. The problem is that I added a thumbnail in order to play the clip, the button must be pressed. The problem is that in debug mode it works without problems, but when I upload it, it does not load. Here is the code
// Automatic FlutterFlow imports
import '/backend/backend.dart';
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 '/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:video_player/video_player.dart';
import 'package:chewie/chewie.dart';
class CustomVideoPlayer extends StatefulWidget {
const CustomVideoPlayer({
Key? key,
this.width,
this.height,
required this.videoUrl,
required this.thumbnailUrl,
required this.progressBarColor,
this.borderRadius = 32,
}) : super(key: key);
final double? width;
final double? height;
final String videoUrl;
final String thumbnailUrl;
final Color progressBarColor;
final double borderRadius;
@override
State<CustomVideoPlayer> createState() => _CustomVideoPlayerState();
}
class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
late VideoPlayerController _controller;
late ChewieController _chewieController;
bool _isPlaying = false;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(widget.videoUrl);
_chewieController = ChewieController(
videoPlayerController: _controller,
autoPlay: false,
looping: false,
aspectRatio: 16 / 9,
allowFullScreen: true,
allowMuting: true,
autoInitialize: false,
showControls: false,
materialProgressColors: ChewieProgressColors(
playedColor: widget.progressBarColor,
handleColor: widget.progressBarColor.withOpacity(0.5),
bufferedColor: widget.progressBarColor.withOpacity(0.5),
backgroundColor: Colors.transparent,
),
);
_controller.addListener(() {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Container(
width: widget.width,
height: widget.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(widget.borderRadius),
image: DecorationImage(
image: NetworkImage(widget.thumbnailUrl),
fit: BoxFit.cover,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(widget.borderRadius),
child: Stack(
children: [
Center(
child: GestureDetector(
onTap: () {
setState(() {
_isPlaying = true;
_initializeAndPlayVideo();
});
},
child: _isPlaying
? Chewie(controller: _chewieController)
: Container(), // Use an empty container here
),
),
if (!_isPlaying)
Center(
child: IconButton(
icon: Icon(Icons.play_arrow),
onPressed: () {
setState(() {
_isPlaying = true;
_initializeAndPlayVideo();
});
},
),
),
],
),
),
);
}
void _initializeAndPlayVideo() {
_chewieController = ChewieController(
videoPlayerController: _controller,
autoPlay: true,
looping: false,
aspectRatio: 16 / 9,
allowFullScreen: true,
allowMuting: true,
autoInitialize: true,
showControls: true,
materialProgressColors: ChewieProgressColors(
playedColor: widget.progressBarColor,
handleColor: widget.progressBarColor.withOpacity(0.5),
bufferedColor: widget.progressBarColor.withOpacity(0.5),
backgroundColor: Colors.transparent,
),
);
setState(() {});
}
@override
void dispose() {
_controller.pause();
_controller.dispose();
_chewieController.dispose();
super.dispose();
}
}