appinioGmbH / flutter_packages

Dart and Flutter plugins/packages used and maintained by @appinioGmbH
193 stars 230 forks source link

[ BUG ] : CachedVideoPlayerController.setLooping(true) makes player not displayed again #237

Open PedroOliveira117 opened 10 months ago

PedroOliveira117 commented 10 months ago

Plugin name Appinio video player version 1.3.0 (also tested with 1.2.2 same happens)

Describe the bug When setLooping(true) on CachedVideoPlayerController everything works fine the first time the video is displayed. The second time it displays the video the video doesn't appear anymore

This is my code: class ArticleDetailVideoWidget extends StatefulWidget { final String videoUrl;

const ArticleDetailVideoWidget(this.videoUrl, {super.key});

@override State createState() => _ArticleDetailVideoWidgetState(); }

class _ArticleDetailVideoWidgetState extends State { late final CachedVideoPlayerController _videoPlayerController; late CustomVideoPlayerController _customVideoPlayerController;

@override void initState() { super.initState(); _videoPlayerController = CachedVideoPlayerController.network( widget.videoUrl, )..initialize()..setLooping(true).then((value) => setState(() {}));

_customVideoPlayerController = CustomVideoPlayerController(
    context: context,
    customVideoPlayerSettings: const CustomVideoPlayerSettings(
        showSeekButtons: true,
        allowVolumeOnSlide: false
    ),
    videoPlayerController: _videoPlayerController
);

}

@override void dispose() { _customVideoPlayerController.dispose(); super.dispose(); }

@override Widget build(BuildContext context) { return AspectRatio( aspectRatio: _customVideoPlayerController.videoPlayerController.value.aspectRatio, // Use the VideoPlayer widget to display the video. child: CustomVideoPlayer(customVideoPlayerController: _customVideoPlayerController), ); } }

Expected behavior Video should always be displayed.

Smartphone (please complete the following information):