How to Play Youtube Embedded Video With Plyr.io Video Player

 

How to Play Youtube Embedded Video With Plyr.io Video Player

How to Play Youtube Embedded Video With Plyr.io Video Player 

See Demo on Repl :- https://repl.it/@SH20RAJ/PlyrVideo#index.html

 

Step 1 :- Add CDNs 

   1. Css CDN before </head> Tag

<!-- Docs styles -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/CDNSFree2/Plyr/plyr.css" />

 2. JS CDN before </body> Tag

<script src="https://cdn.jsdelivr.net/gh/CDNSFree2/Plyr/plyr.js"></script>

 

Step 2 :- 

    Insert Your YouTube iframe Code in Between these div tags :-

        (Here The main thing is to add or assign id="player" to your div element)

<div style="width: 500px;" class="plyr__video-embed" id="player">
    <iframe src="https://www.youtube.com/embed/bTqVqk7FSmY"
        allowfullscreen
        allowtransparency
        allow="autoplay">
    </iframe>
</div>

 

 

Now , Your WebPage Will Look Like :- 

 

PlyrVideo

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Plyr - HTML5 Video Player Sample</title>
  <!-- Docs styles -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.7/plyr.min.css" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-NLYJF7PB3Y"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-NLYJF7PB3Y');
</script>

  </head>
  <body>
    <video
          controls
          crossorigin
          playsinline
          data-poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg"
          id="player"
          width="100%"
        >
          <!-- Video files -->
          <source
            src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4"
            type="video/mp4"
            size="576"
          />
          <source
            src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4"
            type="video/mp4"
            size="720"
          />
          <source
            src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4"
            type="video/mp4"
            size="1080"
          />

          <!-- Caption files -->
          <track
            kind="captions"
            label="English"
            srclang="en"
            src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt"
            default
          />
          <track
            kind="captions"
            label="Français"
            srclang="fr"
            src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"
          />

          <!-- Fallback for browsers that don't support the <video> element -->
          <a href="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4" download>Download</a>
        </video>
        
    <script src="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.7/plyr.min.js"></script>
    <script>const player = new Plyr('#player');</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-NRW057C9V8"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-NRW057C9V8');
</script>
  </body>
</html>

 

Plyr.io Video Player - Integration - Skin Customizing - Adding Download Button

<!-- Docs styles -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/CDNSFree2/Plyr/plyr.css" />

<!--Add a Simple HTML5 Video tag-->
<div id="container">
  <video controls data-poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" class="vid1">
    <!-- Video files -->
    <source src="https://bit.ly/bbsamplevideo" type="video/mp4" size="576" />

    <!-- Caption files -->
    <track kind="captions" label="English" srclang="en" src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt" default />
    <track kind="captions" label="Français" srclang="fr" src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt" />

  </video>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.7/plyr.min.js"></script>

<script>
  var controls =
[
    'play-large', // The large play button in the center
   // 'restart', // Restart playback
   // 'rewind', // Rewind by the seek time (default 10 seconds)
    'play', // Play/pause playback
    'fast-forward', // Fast forward by the seek time (default 10 seconds)
    'progress', // The progress bar and scrubber for playback and buffering
    'current-time', // The current time of playback
    'duration', // The full duration of the media
    'mute', // Toggle mute
    'volume', // Volume control
    'captions', // Toggle captions
    'settings', // Settings menu
    'pip', // Picture-in-picture (currently Safari only)
    'airplay', // Airplay (currently Safari only)
    'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
    'fullscreen' // Toggle fullscreen
];

  const player = new Plyr('.vid1',{controls});
</script>

<style>
  :root {
  --plyr-color-main: #e657ff;
    --plyr-video-control-color  :#e8ffba;
}

</style>

 

 

Integration :- 

 

or Get Plyr CDNS From CDNJS Plyr

 

<!-- Docs styles -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/CDNSFree2/Plyr/plyr.css" />

or Use CDNJS for CDN

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.7/plyr.min.css" />

Skin Customising

<!--Add a Simple HTML5 Video tag-->
  <video controls data-poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" class="vid1">
    <!-- Video files -->
    <source src="https://bit.ly/bbsamplevideo" type="video/mp4" size="576" />
  </video>

<script src="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.7/plyr.min.js"></script>

<script>
  const player = new Plyr('.vid1');
</script>

Links :- 

    Plyr.io Website :- https://plyr.io/

    GitHub & Documentation :- https://github.com/sampotts/plyr#html

Go To GitHub Link and See the readme.md for the documentation.

 

 

See All Classes Here :- Customizing With Css

 

Adding Download Button

var controls =
[
    'play-large', // The large play button in the center
    'restart', // Restart playback
    'rewind', // Rewind by the seek time (default 10 seconds)
    'play', // Play/pause playback
    'fast-forward', // Fast forward by the seek time (default 10 seconds)
    'progress', // The progress bar and scrubber for playback and buffering
    'current-time', // The current time of playback
    'duration', // The full duration of the media
    'mute', // Toggle mute
    'volume', // Volume control
    'captions', // Toggle captions
    'settings', // Settings menu
    'pip', // Picture-in-picture (currently Safari only)
    'airplay', // Airplay (currently Safari only)
    'download', // Show a download button with a link to either the current source or a custom URL you specify in your options
    'fullscreen' // Toggle fullscreen
];

var player = new Plyr('#player', { controls });

Add this code to get All Player Controls. Add or Remove Controls From the Array to See the controls.

See Demo :- https://codepen.io/SH20RAJ/pen/abJdPPP

 

 

Share your thoughts

Previous Post Next Post

نموذج الاتصال