Flutter better_player 使用控制器封装停止和播放视频
我是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的意思是暂停和播放,则只需使用控制器调用它即可。
If you mean pause and play, then just call it by using the controller.