fijkplayer icon indicating copy to clipboard operation
fijkplayer copied to clipboard

如果当前视频正在播放,如何切换视频源 播放下一个用户点击的视频 setDataSource 方法调用了没有反应

Open cocfident opened this issue 4 years ago • 10 comments

cocfident avatar Nov 18 '20 08:11 cocfident

我也遇到了这个问题,请问现在解决了吗

zrodo avatar Nov 25 '20 03:11 zrodo

要先 reset了才能重新赋值播放源,不知道怎么实现无缝切换

yt023 avatar Nov 25 '20 16:11 yt023

要先 reset了才能重新赋值播放源,不知道怎么实现无缝切换

player.reset(); player.setDataSource(url, autoPlay: true); 用了后 还是无法播放,请问还有其他啥需要注意的吗

zrodo avatar Nov 26 '20 03:11 zrodo

FijkPlayer player = map['vc']; player.reset();

  String url = '';
  if (action.payload['type'] == 0) {
    url = map['hls'];
    map['quality'] = 0;
  } else {
    url = map['hlsHd'];
    map['quality'] = 1;
  }
  player.setVolume(0);
  player.setDataSource(url, autoPlay: true);

断点看到player的datasource还是之前的地址,不是后来新的地址

zrodo avatar Nov 26 '20 03:11 zrodo

要先 reset了才能重新赋值播放源,不知道怎么实现无缝切换

现在不支持无缝切换

befovy avatar Nov 26 '20 15:11 befovy

要先 reset了才能重新赋值播放源,不知道怎么实现无缝切换

现在不支持无缝切换

啥时候能支持啊

zrodo avatar Nov 27 '20 00:11 zrodo

我都是用这句话在reset()之后来让下一个视频继续播放的 await Future.delayed(Duration(seconds: 2)).then((_){ player.setDataSource(url, autoPlay: true); });

CoruxoChanot avatar May 12 '21 04:05 CoruxoChanot

我都是用这句话在reset()之后来让下一个视频继续播放的 await Future.delayed(Duration(seconds: 2)).then((_){ player.setDataSource(url, autoPlay: true); });

你这不行。不reset 直接调用setDataSource 不行的

lsfern avatar Jul 03 '21 08:07 lsfern

  Future<void> _setVideoSource(String path) async {
    try {
      await _player.reset();
      _player.removeListener(_onPlayerValueChanged);
      await _player.setDataSource(path, autoPlay: true);
      _player.addListener(_onPlayerValueChanged);
    } catch (e) {
      Log.error('$e');
    }
  }

It works perfectly -- for me.

kostov avatar Aug 24 '23 04:08 kostov

  Future<void> _setVideoSource(String path) async {
    try {
      await _player.reset();
      _player.removeListener(_onPlayerValueChanged);
      await _player.setDataSource(path, autoPlay: true);
      _player.addListener(_onPlayerValueChanged);
    } catch (e) {
      Log.error('$e');
    }
  }

It works perfectly -- for me.

Only your answer is the most accurate. This is indeed caused by the asynchronous mechanism.

Yigehaoren8848 avatar Apr 20 '24 01:04 Yigehaoren8848