bytedance / xgplayer

A HTML5 video player with a parser that saves traffic
https://h5player.bytedance.com/
MIT License
7.99k stars 843 forks source link

记忆倍速和音量 #1513

Closed Hiram-Wong closed 3 days ago

Hiram-Wong commented 6 days ago

您使用的西瓜播放器版本是多少? What version of xgplayer are you using? 3.0.18

您使用的操作系统和浏览器分别是? What OS and browser are you using? macos 15 chrome126

如何复现问题? How to reproduce the problem?

player = new XgPlayer({ ...options });
player.storage = new publicStorage('xgplayer_settings');

if (!options.isLive) player.playbackRate = player.storage.get('playrate') || 1;
player.volume = player.storage.get('volume') || 1;
console.log(1);
publicListener.playrateUpdate = () => {
  player.storage.set('playrate', player.playbackRate);
  console.log(player.playbackRate);
};
player.on(Events.RATE_CHANGE, publicListener.playrateUpdate);

publicListener.volumeUpdate = () => {
  player.storage.set('volume', player.volume);
  console.log(player.volume);
};
player.on(Events.VOLUME_CHANGE, publicListener.volumeUpdate);

想要实现记忆倍速和音量,但是在初始化播放器后,设置记忆倍速和音量后会被默认倍速和音量覆盖

您期望的播放器正常行为是? What did you expect to happen? 初始化播放器后,不覆盖数据

实际播放器的表现是? What actually happened? 初始化播放器后,设置记忆倍速和音量后会被默认倍速和音量覆盖

可填写您所在的公司和相关产品业务,方便我们提供更好的技术支持 You can write your company and product which uses xgplayer, for helping us provide better technical support.

gemxx commented 4 days ago

@Hiram-Wong defaultPlaybackRate & volume 的配置,看看能否满足你的需求?

Hiram-Wong commented 3 days ago

在Events.READY事件中调用可以实现