Video

添加 <video /> 标签,在 Kraken 内部嵌入一个 视频播放器。

快速使用

kraken_video_playerVideo - 图1 作为项目依赖添加到 pubspec.yaml 文件中。

在调用 runApp() 之前添加以下代码:

  1. import 'package:kraken_video_player/kraken_video_player.dart';
  2. void main() { KrakenVideoPlayer.initialize(); runApp(MaterialApp( title: 'Navigation Basics', home: FirstRoute(), ));}

示例

  1. function setElementStyle(dom, object) { if (object == null) return; for (let key in object) { if (object.hasOwnProperty(key)) { dom.style[key] = object[key]; } }}
  2. function setAttributes(dom, object) { for (const key in object) { if (object.hasOwnProperty(key)) { dom.setAttribute(key, object[key]); } }}
  3. const container1 = document.createElement('div');setElementStyle(container1, { height: '500px',});
  4. document.body.appendChild(container1);
  5. const video = document.createElement('video');setElementStyle(video, { width: '750px', height: '400px',});
  6. setAttributes(video, { autoPlay: true, src: 'https://videocdn.taobao.com/oss/ali-video/1fa0c3345eb3433b8af7e995e2013cea/1458900536/video.mp4',});
  7. video.addEventListener('canplay', () => { console.log('vide can play');});
  8. container1.appendChild(video);
  9. const pauseBtn = document.createElement('div');pauseBtn.appendChild(document.createTextNode('pause button'));pauseBtn.addEventListener('click', () => { video.pause();});container1.appendChild(pauseBtn);
  10. const playBtn = document.createElement('div');playBtn.appendChild(document.createTextNode('playBtn button'));playBtn.addEventListener('click', () => { video.play();});container1.appendChild(playBtn);

API

参考: 链接Video - 图2