zhw2590582 / ArtPlayer

:art: ArtPlayer.js is a modern and full featured HTML5 video player
https://artplayer.org
MIT License
2.49k stars 264 forks source link

How to keep currentime and seeking when change quality? #731

Closed begalinsaf closed 5 months ago

begalinsaf commented 5 months ago

when i change the quality why it always reset the current time?

settings: [
{
          name: 'qualities',
          html: 'Quality',
          icon: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-server"><rect width="20" height="8" x="2" y="2" rx="2" ry="2"/><rect width="20" height="8" x="2" y="14" rx="2" ry="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/></svg>',
          width: 250,
          tooltip: '720',
          selector: qualities,
          onSelect: function (item, $dom, event) {

            art.switchUrl(item.url);

            if (item.isM3U8) {
              art.type = 'm3u8';
            } else {
              art.type = 'mp4';
            }

            return item.html;
          },
        },
]

i added this but still not working

      art.on('ready', () => {
        if (type === 'movie' && historyMovie) {
          art.seek = historyMovie.currentTime;
        } else if (type === 'tv' && historyTv) {
          art.seek = historyTv.currentTime;
        }
      });

      art.on('restart', (url) => {
        if (type === 'movie' && historyMovie) {
          art.seek = historyMovie.currentTime;
        } else if (type === 'tv' && historyTv) {
          art.seek = historyTv.currentTime;
        }
      });
begalinsaf commented 5 months ago

i forget to use art.switchQuality sorry my bad