如何自动播放视频,例如flutter上的YouTube应用程序中的视频?

发布于 2025-02-11 19:01:04 字数 303 浏览 2 评论 0 原文

我想创建一个像YouTube一样创建flutter应用程序,我希望我的应用程序具有无限的滚动卡列表,默认情况下,该卡将显示图像。如果用户停止滚动,则只有视口中的第一张卡就会开始播放视频。该视频只能在屏幕上可见时播放,并且一旦移出视口就应该停止。

例如:

我不知道我必须使用哪个包。 YouTube播放器会颤抖吗?

I wanted to create a flutter app just like youtube, I want my app to have an infinite scrolling list of cards where by default the card will display an image. If the user stops scrolling, then only the first card in the viewport will start playing a video. The video should only play while the card is visible on the screen and should stop as soon as it moves out of the viewport.

For example:

https://drive.google.com/file/d/19HMdjrFl8ZbE5TEE3ekq62wMjNl0eWpU/view

I have no idea on which package I have to use. Will flutter youtube player work?

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

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

发布评论

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

评论(3

≈。彩虹 2025-02-18 19:01:04

使用控制器添加listView。考虑一张高度200的卡。现在,如果控制器偏移量为800,则播放该800/200的视频。这是第四。您可以使用任何可以选择并停止视频的视频播放器软件包

Add a listview with a controller. consider a card of height 200. Now if the controller offset is 800 play the video of that 800/200. Which is 4th one. You can use any video player package which has an option to statt and stop video

淡看悲欢离合 2025-02-18 19:01:04

您好检查此软件包并尝试测试它,以查看是否是您的解决方案。
https://pub.dev/packages/inview_notifier_list

Hello check this package and try to test it to see if it is your solution.
https://pub.dev/packages/inview_notifier_list

把梦留给海 2025-02-18 19:01:04

使用 visibilityDetector 检测屏幕上的视频是否可见

 VisibilityDetector(
        key: 'your key',
        onVisibilityChanged: (visibility) {
          //if 80% of the video is visible on the screen
          if (visibility.visibleFraction > 0.0) {
            'play video';
          } else {
           'pause video';
          }
        },
        child: ClipRRect(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(5.0),
            bottomLeft: Radius.circular(5.0),
          ),
          child: VideoPlayer(videoPlayerController!),
        ),
      ),

use VisibilityDetector to detect if the video is visible on the screen

 VisibilityDetector(
        key: 'your key',
        onVisibilityChanged: (visibility) {
          //if 80% of the video is visible on the screen
          if (visibility.visibleFraction > 0.0) {
            'play video';
          } else {
           'pause video';
          }
        },
        child: ClipRRect(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(5.0),
            bottomLeft: Radius.circular(5.0),
          ),
          child: VideoPlayer(videoPlayerController!),
        ),
      ),
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文