sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.64k stars 2.93k forks source link

hls plyr.io not playing on computer #2454

Open sirfpsycho opened 2 years ago

sirfpsycho commented 2 years ago

I am using hls plyr.io. I am trying to play a m3u8 but it only plays on mobile device. On my computer when I open same player it is not playing. Below is my js code. Can any one please help me to add user agent or something like that so that I can play on computer too. Please note that other m3u8 is playing on computer but only one m3u8 is not playing on pc but it plays on mobile fine. So I want to change something so that it can play on all devices.


<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="https://cdn.plyr.io/3.6.8/plyr.polyfilled.js"></script>
                            <video controls preload="metadata" poster="https://i.imgur.com/zPslOur.jpg" id="player" class="plyr">
                              </video>
                              <script>document.addEventListener('DOMContentLoaded', () => {
  const source = 'https://example.com/hls/stream.m3u8';
  const video = document.querySelector('video');

  // For more options see: https://github.com/sampotts/plyr/#options
  // captions.update is required for captions to work with hls.js
  const player = new Plyr(video, { captions: { active: true, update: true, language: 'en' } });

  if (!Hls.isSupported()) {
    video.src = source;
  } else {
    // For more Hls.js options, see https://github.com/dailymotion/hls.js
    const hls = new Hls();
    hls.loadSource(source);
    hls.attachMedia(video);
    window.hls = hls;

    // Handle changing captions
    player.on('languagechange', () => {
      // Caption support is still flaky. See: https://github.com/sampotts/plyr/issues/994
      setTimeout(() => hls.subtitleTrack = player.currentTrack, 50);
    });
  }

  // Expose player so it can be used from the console
  window.player = player;
});</script>
<style>
superman-enamy commented 2 years ago

Getting same Error but Not Get any solution