Better Player show Video Cant play while using in Listview.builder

26 views Asked by At

I am playing video in listview builder after 16,17 videos it show me Video Can't be played retry i try searching alot but nothing for me for now.

Here is my code

    ListView.builder(
  itemCount: videosPostList.length,
  itemBuilder: (context, index) {
    return Column(
      children: [
        VideoPlayerScreen(
          index: index,
          postData: videosPostList[index],
        ),
      ],
    );
  },
)

and this is my VideoPlayerScreen code.

class VideoPlayerScreen extends StatefulWidget {
  final HomePostEntity postData;
  final int index;

  const VideoPlayerScreen({required this.postData, required this.index, Key? key}) : super(key: key);

  @override
  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
}

class _VideoPlayerScreenState extends State<VideoPlayerScreen> with AutomaticKeepAliveClientMixin {
  late BetterPlayerController _betterPlayerController;

  @override
  void initState() {
    super.initState();

    _betterPlayerController = BetterPlayerController(
      BetterPlayerConfiguration(
        autoPlay: false,
        looping: false,
        autoDispose: true,
        aspectRatio: 9/16,
    
        controlsConfiguration: const BetterPlayerControlsConfiguration(
          controlBarColor: Colors.transparent,
          showControlsOnInitialize: false,
          enableQualities: false,
          enablePlaybackSpeed: false,
          enableSkips: false,
        ),
      ),
      betterPlayerDataSource: BetterPlayerDataSource(
        BetterPlayerDataSourceType.network,
        widget.postData.postLink.toString(),
        bufferingConfiguration: const BetterPlayerBufferingConfiguration(minBufferMs: 2000, maxBufferMs: 10000, bufferForPlaybackMs: 1000, bufferForPlaybackAfterRebufferMs: 2000),
        
      ),
    );
  
  }   
  @override
  void dispose() {      
    _betterPlayerController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Stack(
      children: [
        BetterPlayer(
          controller: _betterPlayerController,
        ),
     
      ],
    );
  }

  @override
  bool get wantKeepAlive => true;
}

I am trying to dispose but the controller is not disposing.

0

There are 0 answers