Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>
   <div class="container">
      <h1>
        <span>Html5</span>
        <span>Video</span>
        <span>Player</span>
      </h1>
   </div>
</header>


<div id="videoContainer">

   <div class="overlay">
      <div class="button"></div>
   </div>

   <div id="video">
      <video src="https://goo.gl/q0j3E7">
      </video>
   </div>

   <div id="controls">
      <div class="playButton">
         <div class="playPause"></div>
      </div>

      <div class="ProgressContainer">
         <div class="timer intialTime">
            00:00
         </div>
         <div class="progressBar">
            <div class="progress"></div>
         </div>
         <div class="time">
            00:00
         </div>
         <div class="timer fullTime">
            00:00
         </div>
      </div>

      <div class="volume">
         <div class="icon"></div>

         <div class="intensityBar">
            <div class="intensity"></div>
         </div>
      </div>

      <div class="scale">
         <div class="icon"></div>
      </div>
   </div>

</div>
              
            
!

CSS

              
                $green: #4dbf8c
$red: #e44e4e

$font: 'Open Sans', sans-serif
$mainColor: $green
$seconedColor: darken($mainColor, 10%)


@include general($font, #eee)
@include scrollbar(#555, 4px)

body
   min-height: 100vh
.container
   width: 80%
   margin: 0 auto
   @media (max-width: 768px)
      width: 100%

header
   padding: 20px 0
   text-align: center
   h1
      @include font(50px, 700, #444)
      @media (max-width: 768px)
         font-size: 30px
      @media (max-width: 480px)
         font-size: 25px
      span:first-of-type
         @include font(25px, 300, #222)
      span:last-of-type
         @include font(25px, 300, #222)
   p
      @include font(14px, 400, #666, $lineHeight: 1.6em)
      margin-top: 10px

#videoContainer
   @include dim(70vw, 65vh, $seconedColor)
   margin: 30px auto
   border-radius: 5px
   box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.2)
   margin-bottom: 20px
   position: relative
   overflow: hidden
   -webkit-user-select: none
   -moz-user-select: none
   user-select: none
   &.fullScreen
      @include dim(100vw !important, 100vh !important)

   &.small
      .intensityBar
         width: 50px !important
      .playButton
         margin: 0 !important
         margin-right: 5px !important
      .timer
         display: none !important
      .playPause, .volume .icon,.scale .icon
         @include dim(15px !important, 15px !important)
      .progressBar
         height: 6px !important
      .overlay .button
         @include dim(50px !important, 50px !important)
      .time
         display: none !important


   .overlay
      @include dim(100%, 100%, radial-gradient(circle, rgba($mainColor, 0.9), rgba(darken($mainColor, 22%),0.9)))
      @include pos(absolute, 0, 0)
      z-index: 999
      border-radius: 5px

      .button
         @include dim(80px, 80px)
         @include pos(absolute, 50%, 50%)
         background: url(https://goo.gl/68OJjZ)
         background-size: 100% 100%
         transform: translate(-50%, calc(-50% - 30px))
         cursor: pointer
         transition: width .2s, height .2s
         &:hover
            @include dim(90px, 90px)


   #video
      @include dim(100%, calc(100% - 60px))
      @include pos(relative)
      overflow: hidden
      border-radius: 5px
      border-bottom-left-radius: 0
      border-bottom-right-radius: 0
      video
         @include dim(100%, 100%)
         @include pos(absolute, 0, 0)
         border-radius: 5px
         border-bottom-right-radius: 0
         border-bottom-left-radius: 0
         &::-webkit-media-controls-enclosure
            display: none !important

   #controls
      @include dim(100%, 60px, $mainColor)
      @include pos(absolute, null, null, 0, 0)
      @include flex(center, space-between)
      border-bottom-right-radius: 5px
      border-bottom-left-radius: 5px
      z-index: 2147483647
      &.is-visible
         transform: translateY(0)

      // Play/pause -----------------------------------------
      .playButton
         @include dim(70px, 100%, $mainColor)
         @include flex(center, center)
         margin-right: 20px
         cursor: pointer
         transition: all .4s
         border-bottom-left-radius: 5px
         &:hover
            background: darken($mainColor, 4%)

         .playPause
            @include dim(25px, 25px)
            background: url(https://goo.gl/n3X5YY)
            background-size: 100% 100%


      // Progress -----------------------------------------
      .ProgressContainer
         color: #fff
         @include dim(calc(100% - 100px), 100%)
         @include flex(center, flex-start)
         position: relative

         .progressBar
            @include dim(100%, 8px, $seconedColor)
            border-radius: 20px
            cursor: pointer
            overflow: hidden
            // padding: 3px
            &:hover
               & + .time
                  opacity: 1
                  transform: translateY(0)

            .progress
               @include dim(0%, 100%, #fff)
               border-radius: 20px
         .timer
            margin: 0 10px
            font-family: Arial, sans-serif
            font-weight: 300
            @include font(12px, 300, darken($mainColor, 20%))
            letter-spacing: 1px
         .time
            @include dim(80px, 25px, darken($mainColor, 20%))
            @include pos(absolute, -20px, 0)
            border-radius: 5px
            color: #fff
            font-family: Arial, sans-serif
            text-align: center
            line-height: 25px
            font-size: 12px
            letter-spacing: 1px
            opacity: 0
            transform: translateY(10px)
            transition: transform .3s, opacity .3s
            &::after
               @include triangle-bottom(6px, 6px, 6px, darken($mainColor, 20%), 25px, 33px)



      // Volume -----------------------------------------
      .volume
         @include dim(150px, 100%)
         @include flex(center, flex-end)
         position: relative
         .icon
            @include dim(25px, 25px)
            background: url(https://goo.gl/orkf0V)
            background-size: 100% 100%
            cursor: pointer
            margin-right: 10px

         .intensityBar
            @include dim(100px, 4px, $seconedColor)
            border-radius: 20px
            max-width: 100px
            overflow: hidden
            transform-origin: right center
            cursor: pointer
            transition: all .5s

            .intensity
               @include dim(50%, 100%, #fff)


      // Scale -----------------------------------------
      .scale
         @include dim(70px, 100%, $mainColor)
         @include flex(center, center)
         margin-left: 5px
         cursor: pointer
         transition: all .4s
         border-bottom-right-radius: 5px
         &:hover
            background: darken($mainColor, 5%)
         .icon
            @include dim(25px, 25px)
            @include bg(expand, svg, 100% 100%)
            background: url(https://goo.gl/PZsHVo)
            background-size: 100% 100%

              
            
!

JS

              
                $(document).ready(function () {

    'use strict';

    var play_pause     = $('.playButton'),
        container      = $('#videoContainer'),
        playIcon       = $('.playButton .playPause'),
        video          = $('video'),
        play           = $('.play'),
        volume         = $('.volume .icon'),
        volumeIntesity = $('.volume .intensityBar'),
        intensity      = $('.intensity'),
        progressBar    = $('.progressBar'),
        progress       = $('.progressBar .progress'),
        timer          = $('.intialTime'),
        vidDuration    = $('.fullTime'),
        expandButton   = $('.scale'),
        overlayScreen  = $('.overlay'),
        timeState      = $('.time'),
        overlayButton  = $('.overlay .button'),
        update;


    $(window).resize(function () { resizeVid(); });

    resizeVid();

    updateplayer();

    play_pause.add(video).click(function () { playVid(); });

    progressBar.click(function () {skip(); });

    progressBar.mousemove(function () { timeState.text(getTimeState()); });

    volume.click(function () { toggleMute(); });
  
    expandButton.click(function () {

       $(this).toggleClass('active');

       if ($(this).hasClass('active')) {
         $('#controls').addClass('is-visible');
         fullScreen();
      } else {
         $('#controls').removeClass('is-visible');
         exitTheFullScreen();
      }
   });

    volumeIntesity.click(function () { changeVolume(); });

    overlayButton.click(function () { playVid();});
  
    vidDuration.text(getFormatedFullTime());


    function playVid() {
        if (video.get(0).paused) {
            video.get(0).play();
            playIcon.css({
               'background': 'url(https://goo.gl/OnSWWI)',
               'background-size': '100% 100%'
            });
            overlayScreen.hide();
            update = setInterval(updateplayer, 1);

        } else {
            video.get(0).pause();
            playIcon.css({
               'background': 'url(https://goo.gl/n3X5YY)',
               'background-size': '100% 100%'
            });
            overlayScreen.show();
            clearInterval(update);
        }
    }
  
    function updateplayer() {
        var percentage = (video[0].currentTime / video[0].duration) * 100;
        progress.css({'width': percentage + '%'});
        timer.text(getFormatedTime());
        vidDuration.text(getFormatedFullTime());

        if (video[0].ended) {
            playIcon.css({
               'background': 'url(https://goo.gl/n3X5YY)',
               'background-size': '100% 100%'
            });
            overlayScreen.show();
            overlayButton.css({
               'background': 'url(https://goo.gl/MaF14e)',
               'background-size': '100% 100%'
            });
        } else if (video[0].paused) {
            overlayButton.css({
               'background': 'url(https://goo.gl/68OJjZ)',
               'background-size': '100% 100%'
            });
        }
    }

    function getTimeState() {

      var mouseX = event.pageX - progressBar.offset().left,
          width  = progressBar.outerWidth();

       var currentSeconeds = Math.round((mouseX / width) * video[0].duration);
       var currentMinutes  = Math.floor(currentSeconeds/60);

       if (currentMinutes > 0) {
          currentSeconeds -= currentMinutes * 60;
       }
       if (currentSeconeds.toString().length === 1) {
           currentSeconeds = "0" + currentSeconeds;
        }
        if (currentMinutes.toString().length === 1) {
            currentMinutes = "0" + currentMinutes;
        }

        timeState.css('left', (mouseX / width) * progressBar.width() + 18 + 'px');

        return currentMinutes + ':' + currentSeconeds;

    }

    function skip() {
        var mouseX = event.pageX - progressBar.offset().left,
            width  = progressBar.outerWidth();
       video[0].currentTime = (mouseX / width) * video[0].duration;
       updateplayer();
    }

    function getFormatedFullTime() {

         var totalSeconeds = Math.round(video[0].duration);
         var totalMinutes  = Math.floor(totalSeconeds/60);
         if (totalMinutes > 0) {
            totalSeconeds -= totalMinutes * 60;
         }
         if (totalSeconeds.toString().length === 1) {
             totalSeconeds = "0" + totalSeconeds;
          }
          if (totalMinutes.toString().length === 1) {
              totalMinutes = "0" + totalMinutes;
          }
        return totalMinutes + ':' + totalSeconeds;
    }

     function getFormatedTime() {
         var seconeds = Math.round(video[0].currentTime);
         var minutes  = Math.floor(seconeds / 60);

          if (minutes > 0) {
            seconeds -= minutes * 60;
         }
         if (seconeds.toString().length === 1) {
             seconeds = "0" + seconeds;
          }
          if (minutes.toString().length === 1) {
              minutes = "0" + minutes;
          }
         return minutes + ':' + seconeds;
     }

    function toggleMute() {
        if (!video[0].muted) {
           video[0].muted = true;
           volume.css({
              'background': 'url(https://goo.gl/AzCoUk)',
              'background-size': '100% 100%'
           });
           intensity.hide();
        } else {
           video[0].muted = false;
           volume.css({
              'background': 'url(https://goo.gl/orkf0V)',
              'background-size': '100% 100%'
           });
           intensity.show();
        }
    }

    function changeVolume() {
       var mouseX = event.pageX - volumeIntesity.offset().left,
           width  = volumeIntesity.outerWidth();

       video[0].volume = (mouseX / width);
       intensity.css('width', (mouseX / width) * width + 'px');
       video[0].muted = false;
       volume.css({
          'background': 'url(https://goo.gl/orkf0V)',
          'background-size': '100% 100%'
       });
       intensity.show();
    }

    function fullScreen() {
        if (video[0].requestFullscreen) {
           video[0].requestFullscreen();
        } else if (video[0].webkitRequestFullscreen) {
           video[0].webkitRequestFullscreen();
        } else if (video[0].mozRequestFullscreen) {
           video[0].mozRequestFullscreen();
        } else if (video[0].msRequestFullscreen) {
           video[0].msRequestFullscreen();
        } else {
           video.dblclick(function () { fullScreen(); });
        }

    }
  
    function exitTheFullScreen() {
        if (document.webkitExitFullscreen()) {
           document.webkitExitFullscreen();
        } else if (document.mozCancelFullScreen()) {
           document.mozCancelFullScreen();
        } else if (document.msExitFullscreen()) {
           document.msExitFullscreen();
        } else {
           video.dblclick(function () { fullScreen(); });
        }
    }

    function resizeVid() {
       if (container.width() < 600) {
          container.addClass('small');
       } else {
          container.removeClass('small');
       }
    }

    $(window).keypress(function (e) {
       if (e.keyCode === 0 || e.keyCode === 32) {
          e.preventDefault()
          playVid();
       }
    });
  
    for (var i = 0, l = videos.length; i < l; i++) {
    var video = videos[i];
    var src = video.src || (function () {
        var sources = video.querySelectorAll("source");
        for (var j = 0, sl = sources.length; j < sl; j++) {
            var source = sources[j];
            var type = source.type;
            var isMp4 = type.indexOf("mp4") != -1;
            if (isMp4) return source.src;
        }
        return null;
    })();
    if (src) {
        var isYoutube = src && src.match(/(?:youtu|youtube)(?:\.com|\.be)\/([\w\W]+)/i);
        if (isYoutube) {
            var id = isYoutube[1].match(/watch\?v=|[\w\W]+/gi);
            id = (id.length > 1) ? id.splice(1) : id;
            id = id.toString();
            var mp4url = "http://www.youtubeinmp4.com/redirect.php?video=";
            video.src = mp4url + id;
        }
    }
}


});

              
            
!
999px

Console