flutter_vlc_player icon indicating copy to clipboard operation
flutter_vlc_player copied to clipboard

Unhandled Exception: LateInitializationError: Field '_viewId@862035241' has not been initialized. E/flutter (23559): #0 VlcPlayerController._viewId (package:flutter_vlc_player/src/vlc_player_controller.dar

Open omkarChend1kar opened this issue 2 years ago • 8 comments

I am trying load durations videos for which I am fetching http url stored in firebase database inside Listview.builder but facing this issue, I have tried accessing vlcplayervalue wherein isIntialized says false, I am not able to why playingstate still says initializing

This is my code:-

class VideoTitles extends StatefulWidget { const VideoTitles({ Key? key, required this.url, required this.title, }) : super(key: key); final String url; final String title;

@override State<VideoTitles> createState() => _VideoTitlesState(); }

class _VideoTitlesState extends State<VideoTitles> { VlcPlayerController? _videoPlayerController;

@override void initState() { super.initState(); _videoPlayerController = VlcPlayerController.network( widget.url, ); }

@override void dispose() async { super.dispose(); await _videoPlayerController!.dispose(); }

@override Widget build(BuildContext context) { return FutureBuilder( future: _videoPlayerController!.initialize(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done && _videoPlayerController!.value.isInitialized) { return Container( child: Column( children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text(widget.title), ), Padding( padding: const EdgeInsets.all(8.0), child: Text(_videoPlayerController!.value.duration .toString() .substring(2, 7)), ), Text(_videoPlayerController!.value.toString()) ], ), ); } else { return Center( child: CircularProgressIndicator( color: Color(0xFF7860DC), ), ); } }, ); } }

omkarChend1kar avatar May 20 '22 09:05 omkarChend1kar

I get the same error when i try to initialize a VlcPlayerController

rasphlat avatar May 31 '22 16:05 rasphlat

Me too, it only works with autoInitialize: true

mathisxy avatar Jul 16 '22 12:07 mathisxy

In order to initialize the video Controller, first the Video Widget must be built with the controller along with dataSource. if u try to call initialize method in FutureBuilder since the Video widget is not built yet u will get an error. Solution 1. Remove FutureBuilder directly provide the controller to the video widget after setting URL (DataSource) to the controller in initState and setting the autoInitialize to true. Solution 2. Set autoInitialize to false during controller initialization in initState and call the controller.initialize after the build method is built(use WidgetsBinding.instance.addPostFrameCallback to wait for build method to complete then wait for half sec then call controller.initialize method)

PurshuRana avatar Feb 10 '23 09:02 PurshuRana

Almost a year & a month and no solution ??

ThisIsMonta avatar Jun 12 '23 16:06 ThisIsMonta