befovy / fijkplayer

ijkplayer for flutter. ijkplayer 的 flutter 封装。 Flutter video/audio player. Flutter media player plugin for android/iOS based on ijkplayer. fijkplayer 是基于 ijkplayer 封装的 flutter 媒体播放器,开箱即用,无需编译 ijkplayer
https://fijkplayer.befovy.com
MIT License
1.63k stars 341 forks source link

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

Open cocfident opened 3 years ago

zrodo commented 3 years ago

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

yt023 commented 3 years ago

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

zrodo commented 3 years ago

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

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

zrodo commented 3 years ago

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还是之前的地址,不是后来新的地址

befovy commented 3 years ago

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

现在不支持无缝切换

zrodo commented 3 years ago

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

现在不支持无缝切换

啥时候能支持啊

CoruxoChanot commented 3 years ago

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

lsfern commented 3 years ago

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

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

kostov commented 1 year ago
  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.

Yigehaoren8848 commented 4 months ago
  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.