Flutter video_player 插件 - 在 VideoPlayerController 初始化后更改 ClosedCaptionFile

发布于 2025-01-13 23:27:08 字数 218 浏览 4 评论 0原文

我在 Flutter 应用程序中使用 video_player 插件,当我想添加字幕文件时,我必须为 VideoPlayerController 的初始化方法指定一个 Future。而且在控制器初始化后我找不到任何方法来更改标题。但我尝试了一种方法,我在 video_player 源代码中添加了一个名为 setClosedCaptionFile 的方法,并且它正在工作。但我想知道是否有其他(正确的)方法来更改字幕文件?

I am using video_player plugin in my Flutter app and when I want to add a caption file I have to specifice a Future to the initialize method of VideoPlayerController. And I cannot find any way to change captions after the controller is initialized. But I have tried a way, I have added a method called setClosedCaptionFile in video_player source code and it is working. But I am wondering is there any other(correct) way to change the caption file?

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

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

发布评论

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

评论(2

南巷近海 2025-01-20 23:27:08

将插件更新到最新版本,他们在上次更新 2.4.0 中添加了 setClosedCaptionFile

检查一下 这里

update the plugin to the latest version, they added setClosedCaptionFile in the last update 2.4.0

check it here

放肆 2025-01-20 23:27:08

要添加奥马尔答案,您还可以使用 VideoPlayerController 的 linedCaptionFile 属性直接使用 CaptionFile 初始化控制器:

controller = VideoPlayerController.network(
url,
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),  
closedCaptionFile: closedCaptionFile);

To add on omar answer you can also directly initialize the controller with the CaptionFile with the closedCaptionFile property of VideoPlayerController:

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