Chew ie видео продолжает воспроизводиться, когда я ухожу со страницы на Flutter - PullRequest
0 голосов
/ 06 мая 2020

У меня есть приложение во Flutter, которое показывает видео с Chew ie. Когда я ухожу с экрана, на котором воспроизводится видео, видео продолжает воспроизводиться. Виджет, которым управляет Chew ie, - это

    class _crearVideo extends StatefulWidget {

 final video;

  const _crearVideo({this.video});

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

class __crearVideoState extends State<_crearVideo> {

  VideoPlayerController _videoPlayerController1;
  ChewieController _chewieController;

  @override
  void dispose() {
    _chewieController.pause();
    _chewieController.dispose();
    _videoPlayerController1.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

    _videoPlayerController1 = VideoPlayerController.network( GlobalConfiguration().getString("rest_server") + "/v1/videoStream/${widget.video.video}");
    _chewieController = ChewieController(
      videoPlayerController: _videoPlayerController1,
      aspectRatio: 16 / 9,
      autoPlay: false,
      looping: false,
      // Try playing around with some of these other options:

      // showControls: false,
      materialProgressColors: ChewieProgressColors(
      //   playedColor: Colors.red,
      //   handleColor: Colors.blue,
      //   backgroundColor: Colors.grey,
         bufferedColor: Colors.orangeAccent,
      // ),
      // placeholder: Container(
      //   color: Colors.grey,
       ),
       autoInitialize: true,
    );

    return Container(
       child: Chewie(
                  controller: _chewieController,
                ));
  }
}

У меня есть метод dispose (), который выполняется, но не работает.

Есть идеи?

Спасибо и извините за мой Engli sh.

1 Ответ

0 голосов
/ 23 июля 2020

В кнопке возврата необходимо ввести: Navigator.popAndPushNamed (context, 'Here you can name your route');

Пример:

IconButton(
                  onPressed: (){
                    Navigator.popAndPushNamed(context, '/ConsultantConsulting');
                     },
                  icon: Icon(Icons.arrow_back, color: Colors.white, size: 30,),
                )

Для создания именованных маршрутов. то, что находится между кавычками, будет тем, что вы будете использовать для вызова маршрута. (main.dart):

initialRoute: '/',
routes: {
  '/': (context) => HomePage(),
  '/login': (context) => LoginPage()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...