1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter media_kit: Always show play button or `primaryButtonBar` when video paused?

Discussão em 'Mobile' iniciado por Stack, Outubro 10, 2024 às 04:53.

  1. Stack

    Stack Membro Participativo

    I am using media_kit package to display a video. Right now, the controls are hidden where there is no mouse movement for specified controlsHoverDuration. As a workaround, I can set the controlsHoverDuration to a long duration.

    MaterialVideoControlsTheme(
    normal: const MaterialVideoControlsThemeData(
    visibleOnMount: true,
    controlsHoverDuration: Duration(hours: 1) // Setting this value to a duration
    ),
    fullscreen: const MaterialVideoControlsThemeData(),
    child: Scaffold(
    body: Video(
    controller: controller,
    ),
    ),
    );


    but that hides the controls when I tap the video.

    Another way is to build custom video controls.

    Scaffold(
    body: Video(
    controller: _controller,
    controls: (state) {
    return Center(
    child: IconButton(
    onPressed: () {
    state.widget.controller.player.playOrPause();
    },
    icon: StreamBuilder(
    stream: state.widget.controller.player.stream.playing,
    builder: (context, playing) => Icon(
    playing.data == true ? Icons.pause : Icons.play_arrow,
    ),
    ),
    ),
    );
    },
    ),
    );


    but that requires implementation of all states for a simple requirement. Also I want to stick to MaterialVideoControlsTheme.

    Is there a way to always show the play button or primaryButtonBar when the video is in pause state using MaterialVideoControlsTheme?

    Continue reading...

Compartilhe esta Página