在颤动的网络中播放视频 [英] play video in flutter web

查看:67
本文介绍了在颤动的网络中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用最近启动的flutter_web创建一个Web应用程序,但是在应用程序内部播放视频时遇到了问题.有人可以指导我如何在flutter_web中播放视频.

I am trying to create a web app using recently launched flutter_web, but facing issues in playing a video inside my app. Can someone guide me how to play a video in flutter_web.

  1. 我试图为flutter web创建一个Web插件,但是作为flutter_web的官方文档,我们无法为web创建一个插件.
  2. 我试图在index.html中添加视频和iframe广告代码,但没有运气.
  3. 我尝试使用dart:html提供的VideoElement,但不确定如何使用它.

prefix1.VideoElement element = prefix1.VideoElement();
    element.height = 200;
    element.width = 200;
    element.appendHtml("""<video width="400" controls>
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>
    """);
    element.querySelector('#video');
    element.play();

推荐答案

您现在可以通过将官方video_player_web插件添加到pubspec.yaml中来使用它:

You can now just use the official video_player_web plugin by adding it to your pubspec.yaml:

video_player: ^0.10.4+1
video_player_web: ^0.1.0

然后,您可以按照视频播放器食谱或使用 chewie插件,以获得漂亮的用户界面.

Then you can follow the video player cookbook or use the chewie plugin to get a nice UI.

这篇关于在颤动的网络中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆