video_player close connection after 1 minute

This issue has been tracked since 2022-09-23.

Hi
I initialize video player for stream live video. everything is ok but when I back from player screen and check active connection on the server, my connection still open and close after 20~60 second. how to to fix it?

Code sample
void _initializeAndPlay(String link) async {
    print("_initializeAndPlay ---------> $link");

    final controller = VideoPlayerController.network(link);

    VideoPlayerController? old = _controller;
    _controller = controller;
    if (old != null) {
      old.pause();
      debugPrint("---- old contoller paused.");
    }

    debugPrint("---- controller changed.");
    setState(() {});

    controller..initialize().then((_) {
        debugPrint("---- controller initialized");
        old?.dispose();
        old = null;
        controller.play();
        setState(() {});
      });
  }

  @override
  void initState() {
    Wakelock.enable();
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);

    final clip = _channelModel.qualities[0].channel_category;
    selectedQuality = _channelModel.qualities[0];
    _initializeAndPlay(clip.link);

    initVolumeAndBrightnessState();

    super.initState();
  }

  @override
  void dispose() async{
    super.dispose();
    _disposed = true;
    _timerVisibleControl?.cancel();
    Wakelock.disable();
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    _exitFullScreen();
    _controller?.removeListener(() { });
    await _controller?.pause(); // mute instantly
    await _controller?.dispose();
    _controller = null;
  }
exaby73 wrote this answer on 2022-09-23

Hi @iranandroid
This issue doesn't seem to describe a bug or a feature request. Please see https://flutter.dev/community for resources and asking questions like this,
you may also get some help if you post it on Stack Overflow and if you need help with your code, please see https://www.reddit.com/r/flutterhelp/
Closing, as this isn't an issue with Flutter itself. If you disagree, please write in the comments and I will reopen it.
Thank you

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-09-30
Star Count 145381
Watcher Count 3565
Fork Count 23363
Issue Count 11208

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date