小编Bob*_*Lin的帖子

如何在 Flutter 中播放视频列表?

我正在使用 fluttervideo_player包来播放视频列表。

List sourceList;

sourceList = [
  {
    "size": 69742504,
    "name": "lucky-roulette.mp4",
    "mimetype": "video/mp4",
  },
  {
    "size": 69742504,
    "name": "BigBuckBunny.mp4",
    "mimetype": "video/mp4",
  }
];
Run Code Online (Sandbox Code Playgroud)

我已经检查了这个问题,并在上面做了一些自定义代码。

void play() {
  log.fine("Now playing: $_nowPlayingUrl");
  _adController = VideoPlayerController.network(_nowPlayingUrl);
  _adController.initialize().then((_) => setState(() {}));
  _adController.play();
  _adController.addListener(checkIfVideoFinished);
}

void checkIfVideoFinished() {
  if (_adController == null ||
      _adController.value == null ||
      _adController.value.position == null ||
      _adController.value.duration == null) return;
  if (_adController.value.position.inSeconds ==
      _adController.value.duration.inSeconds) {
    _adController.removeListener(checkIfVideoFinished);
    _adController.dispose();
    // Change _nowPlayingIndex
    setState(() {
      _nowPlayingIndex = (_nowPlayingIndex …
Run Code Online (Sandbox Code Playgroud)

video dart video-player flutter

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

dart ×1

flutter ×1

video ×1

video-player ×1