使用 querySelector jquery 更改源不起作用

Changing source with querySelector jquery dont work

我正在使用带有简单播放列表的 Plyr 播放器。我有一个 j.code 用于更改视频源,但它仅适用于本机播放器,但不适用于 Plyr。使用 Plyr 启动控制台响应 TypeError: player.querySelector is not a function。可以在此处查看整个框架 - https://special.novinky.cz/pocasi/index.html 函数代码如下

document.querySelectorAll('.video-link').forEach(link => {
      link.addEventListener('click', function() {
        const videoUrl = link.dataset.videoLinkUrl;
        player.source = videoUrl;
        player.querySelector('source').setAttribute('src', videoUrl);
        player.load();
        player.play();
        console.log('link.dataset.videoLinkUrl', link.dataset.videoLinkUrl);
      });
    });

玩家被放置在此

<video poster="https://special.novinky.cz/pocasi/img/pocasi.jpg" id="player" playsinline controls>
  <source src="https://special.novinky.cz/pocasi/video/cizinsky.mp4" type="video/mp4">
</video>

并由此开始

<script src="js/plyr.js"></script>
<script>const player = new Plyr('#player');</script>

所以我找到了解决方案。这很奇怪,但它正在工作。

document.querySelectorAll(".video-link").forEach(function(link) {
  link.addEventListener("click", function() {
    const videoUrl = link.dataset.videoLinkUrl;
    player.source = {
      type: "video",
      title: "video_title",
      sources: [
        {
          src: videoUrl,
          type: "video/mp4"
        }
      ]
    };
  });
});