Instagram Style HTML5 Video Player
How do I make an instagram style html5 video player?
Http://css-tricks.com/custom-controls-in-html5-video-full-screen/. What is a instagram style html5 video player? How do you make a instagram style html5 video player? This script and codes were developed by Travis Arnold on 12 September 2022, Monday.
Instagram Style HTML5 Video Player - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Instagram Style HTML5 Video Player</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ video { max-width: 100%;
}
.video-wrapper { display: inline-block; position: relative; z-index: 100;
}
.video-controls { opacity: 0; transition: opacity .35s ease-out;
}
.video-controls--show { opacity: 1;
}
[data-media] { padding: 0; margin: 0; background-color: transparent;
}
[data-media="play-pause"] { display: block; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 1; transition: opacity .35s ease-out;
}
.paused [data-media="play-pause"] { width: 0; height: 0; border-style: solid; border-width: 30px 0 30px 52px; border-color: transparent transparent transparent #fff;
}
.playing [data-media="play-pause"] { width: 52px; height: 60px; border: 16px solid #fff; border-top: none; border-bottom: none;
}
.hide-playhead [data-media="play-pause"] { opacity: 0;
}
[data-media="mute-unmute"] { display: block; width: 15px; height: 15px; background-color: red; position: absolute; top: 20px; right: 20px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="video-wrapper"> <video width="640" height="360" controls> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4"></source> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg"></source> Your browser does not support the <code>video</code> tag. </video> <div class="video-controls"> <button data-media="play-pause"></button> <button data-media="mute-unmute"></button> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Instagram Style HTML5 Video Player - Script Codes CSS Codes
video { max-width: 100%;
}
.video-wrapper { display: inline-block; position: relative; z-index: 100;
}
.video-controls { opacity: 0; transition: opacity .35s ease-out;
}
.video-controls--show { opacity: 1;
}
[data-media] { padding: 0; margin: 0; background-color: transparent;
}
[data-media="play-pause"] { display: block; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 1; transition: opacity .35s ease-out;
}
.paused [data-media="play-pause"] { width: 0; height: 0; border-style: solid; border-width: 30px 0 30px 52px; border-color: transparent transparent transparent #fff;
}
.playing [data-media="play-pause"] { width: 52px; height: 60px; border: 16px solid #fff; border-top: none; border-bottom: none;
}
.hide-playhead [data-media="play-pause"] { opacity: 0;
}
[data-media="mute-unmute"] { display: block; width: 15px; height: 15px; background-color: red; position: absolute; top: 20px; right: 20px;
}
Instagram Style HTML5 Video Player - Script Codes JS Codes
'use strict';
var InstaVideo = function (el) { this.$video = $(el); this.$wrapper = $(el).parent().addClass('paused'); this.$controls = this.$wrapper.find('.video-controls'); // remove native controls this.$video.removeAttr('controls'); // check if video should autoplay if(!!this.$video.attr('autoplay')) { this.$wrapper.removeClass('paused').addClass('playing'); } // check if video is muted if(this.$video.attr('muted') === 'true' || this.$video[0].volume === 0) { this.$video[0].muted = true; this.$wrapper.addClass('muted'); } // attach event handlers this.attachEvents();
};
InstaVideo.prototype.attachEvents = function () { var self = this, _t; // keep track of timeout for controls // attach handlers to data attributes this.$wrapper.on('click', '[data-media]', function () { var data = $(this).data('media'); if(data === 'play-pause') { self.playPause(); } if(data === 'mute-unmute') { self.muteUnmute(); } }); this.$video.on('click', function () { self.playPause(); }); this.$video.on('play', function () { self.$wrapper.removeClass('paused').addClass('playing'); }); this.$video.on('pause', function () { self.$wrapper.removeClass('playing').addClass('paused'); }); this.$video.on('volumechange', function () { if($(this)[0].muted) { self.$wrapper.addClass('muted'); } else { self.$wrapper.removeClass('muted'); } }); this.$wrapper.on('mousemove', function () { // show controls self.$controls.addClass('video-controls--show'); // clear original timeout clearTimeout(_t); // start a new one to hide controls after specified time _t = setTimeout(function () { self.$controls.removeClass('video-controls--show'); }, 2250); }).on('mouseleave', function () { self.$controls.removeClass('video-controls--show'); });
};
InstaVideo.prototype.playPause = function () { if (this.$video[0].paused) { this.$video[0].play(); } else { this.$video[0].pause(); }
};
InstaVideo.prototype.muteUnmute = function () { if(this.$video[0].muted === false) { this.$video[0].muted = true; } else { this.$video[0].muted = false; }
};
$('video').each(function () { new InstaVideo(this);
});
Developer | Travis Arnold |
Username | souporserious |
Uploaded | September 12, 2022 |
Rating | 3 |
Size | 3,902 Kb |
Views | 97,152 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Simplistic WYSIWYG Editor | 3,740 Kb |
Trix Custom Toolbar | 3,356 Kb |
Raidial Loader | 2,565 Kb |
React Circle Media Player | 5,566 Kb |
Hamburglar | 3,457 Kb |
React Vote Component | 5,465 Kb |
Material CSS Switch | 2,979 Kb |
Animated heading using css and javascript | 3,516 Kb |
React Measure Demo | 3,718 Kb |
Expose - a responsive jQuery modal plugin | 3,754 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Responsive Pricing Table | Jeremycaris | 2,690 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Atom | Bhlaird | 1,932 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Apple website | Jds317 | 1,835 Kb |
Spinners using Font Icons | Keyamoon | 3,007 Kb |
Bezier Animation with straight paths | Rhernando | 2,087 Kb |
CSS Grid Overlay | Cliffpyles | 3,090 Kb |
Fixed Scrolling Nav Bar | Philsinatra | 0 Kb |
Filtre ile Arama Kutusu - Search Box with Filter | AyhanALTINOK | 3,448 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!