Flutter better_player 使用控制器封装停止和播放视频

发布于 2025-01-12 07:16:07 字数 827 浏览 4 评论 0原文

我是 flutter 新手,目前使用 better_player: ^0.0.81 包。

有没有办法使用控制器停止视频?这是我下面的代码

late BetterPlayerController _betterPlayerController;

Function

_betterPlayerController = BetterPlayerController(
  const BetterPlayerConfiguration(
    autoPlay: true,
    fit: BoxFit.contain,
    controlsConfiguration: BetterPlayerControlsConfiguration(
      enableOverflowMenu: false,
      showControlsOnInitialize: false,
      enableRetry: true,
      showControls: true,
    ),
  ),
  betterPlayerDataSource: BetterPlayerDataSource.file(videoPath),
);

Widget

  AspectRatio(
       aspectRatio: 16 / 9,
       child: BetterPlayer(
                controller: _betterPlayerController,
       ),
   )

I'm new with flutter and currently using better_player: ^0.0.81 package.

Is there anyway to stop the video using a controller? Here is my code below

late BetterPlayerController _betterPlayerController;

Function

_betterPlayerController = BetterPlayerController(
  const BetterPlayerConfiguration(
    autoPlay: true,
    fit: BoxFit.contain,
    controlsConfiguration: BetterPlayerControlsConfiguration(
      enableOverflowMenu: false,
      showControlsOnInitialize: false,
      enableRetry: true,
      showControls: true,
    ),
  ),
  betterPlayerDataSource: BetterPlayerDataSource.file(videoPath),
);

Widget

  AspectRatio(
       aspectRatio: 16 / 9,
       child: BetterPlayer(
                controller: _betterPlayerController,
       ),
   )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流心雨 2025-01-19 07:16:07

如果您的意思是暂停和播放,则只需使用控制器调用它即可。

eg: _betterPlayerController.pause();  or  _betterPlayerController.play();

If you mean pause and play, then just call it by using the controller.

eg: _betterPlayerController.pause();  or  _betterPlayerController.play();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文