how to troubleshoot html5 video not playing using Coverr's code - html5-video

I've uploaded a video from Coverr, and added the HTML, CSS, and JS to my home page.
However, the video does not play.
HTML:
<div class="homepage-hero-module">
<div class="video-container">
<div class="filter"></div>
<video autoplay loop class="fillWidth">
<source src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.mp4" type="video/mp4" ></source>Your browser does not support the video tag. I suggest you upgrade your browser.
<source src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.webm" type="video/webm" ></source>Your browser does not support the video tag. I suggest you upgrade your browser.
</video>
<div class="poster hidden"><img src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.jpg" alt="Escalate your business internet success with the help of a web professional"></div>
</div>
</div>
CSS:
<style>
.homepage-hero-module {
border-right: none;
border-left: none;
position: relative;
}
.no-video .video-container video,
.touch .video-container video {
display: none;
}
.no-video .video-container .poster,
.touch .video-container .poster {
display: block !important;
}
.video-container {
position: relative;
bottom: 0%;
left: 0%;
height: 100%;
width: 100%;
overflow: hidden;
background: #000;
}
.video-container .poster img {
width: 100%;
bottom: 0;
position: absolute;
}
.video-container .filter {
z-index: 100;
position: absolute;
background: rgba(0, 0, 0, 0.4);
width: 100%;
}
.video-container video {
position: absolute;
z-index: 0;
bottom: 0;
}
.video-container video.fillWidth {
width: 100%;
}
</style>
JS:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
//jQuery is required to run this code
jQuery( document ).ready(function() {
scaleVideoContainer();
initBannerVideoSize('.video-container .poster img');
initBannerVideoSize('.video-container .filter');
initBannerVideoSize('.video-container video');
jQuery(window).on('resize', function() {
scaleVideoContainer();
scaleBannerVideoSize('.video-container .poster img');
scaleBannerVideoSize('.video-container .filter');
scaleBannerVideoSize('.video-container video');
});
});
function scaleVideoContainer() {
var height = jQuery(window).height() + 5;
var unitHeight = parseInt(height) + 'px';
jQuery('.homepage-hero-module').css('height',unitHeight);
}
function initBannerVideoSize(element){
jQuery(element).each(function(){
jQuery(this).data('height', jQuery(this).height());
jQuery(this).data('width', jQuery(this).width());
});
scaleBannerVideoSize(element);
}
function scaleBannerVideoSize(element){
var windowWidth = jQuery(window).width(),
windowHeight = jQuery(window).height() + 5,
videoWidth,
videoHeight;
console.log(windowHeight);
jQuery(element).each(function(){
var videoAspectRatio = jQuery(this).data('height')/jQuery(this).data('width');
jQuery(this).width(windowWidth);
if(windowWidth < 1000){
videoHeight = windowHeight;
videoWidth = videoHeight / videoAspectRatio;
jQuery(this).css({'margin-top' : 0, 'margin-left' : -(videoWidth - windowWidth) / 2 + 'px'});
jQuery(this).width(videoWidth).height(videoHeight);
}
jQuery('.homepage-hero-module .video-container video').addClass('fadeIn animated');
});
}
</script>
I see no errors in the console, so I don't know why the video does not play in the latest versions of Chrome or Firefox.
Help appreciated.

Your video is actually playing but it's hidden under your poster div. Unless you have another reason to use a seperate div for the poster, you should consider using the poster attribute for the video element like so:
<video autoplay loop class="fillWidth" poster="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.jpg">
<source src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.mp4" type="video/mp4" ></source>
<source src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.webm" type="video/webm" ></source>Your browser does not support the video tag. I suggest you upgrade your browser.
</video>
But if you have the autoplay attribute you won't need the poster, except perhaps when the video loads slowly.
To annotate the video with text you can do something like this:
<div class="video-container">
<div class="filter"></div>
<video loop class="fillWidth" poster="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.jpg">
<source src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.mp4" type="video/mp4" ></source>
<source src="https://doig.website.technology/wp-content/uploads/2016/09/Escalate.webm" type="video/webm" ></source>Your browser does not support the video tag. I suggest you upgrade your browser.
</video>
<div class="video-annotation-layer">
<div id="video-annotation-1">Hello there!!</div>
<div id="video-annotation-2">Hey buddy!!</div></div>
</div>
Then in CSS:
.video-annotation-layer{
width:100%;
height:100%;
}
#video-annotation-1{
position:absolute;
top:40%;
left:40%;
font-size:50px;
text-align:center;
}
#video-annotation-2{
position:absolute;
top:60%;
left:30%;
color:blue;
background-color:white;
font-size:40px;
text-align:center;
}

Related

How to update iframe in vue.js

I have an Iframe
<iframe v-show="this.$store.getters['rackStore/getIframe'].show === 'iframe'" ref="iframe_3d" :src="this.$store.getters['rackStore/getIframe'].ref" id="iframe_3d" allowfullscreen="true" style="width: 100%; height: 100%; z-index: -1; position: fixed; top: 0px; left: 0px; border: 1px solid #00f; "></iframe>
And it displays the data perfectly.
Src I take from Vuex
Then I want to change the src value:
let iframe_param = this.$store.getters['rackStore/getIframe'];
this.$store.commit('rackStore/setIframe', { ...iframe_param, show: 'iframe', ref: model.ref } );
And I mean in the console that the src value of the iframe is changing!
But the iframe itself is not updated in the browser for some reason.
I tried to force update it: this.$ForceUpdate ();
This does not work.
I've tried changing the src in the usual way without Vue, this also doesn't work:
<iframe v-show="this.$store.getters['rackStore/getIframe'].show === 'iframe'" ref="iframe_3d"
src="" id="iframe_3d"
allowfullscreen="true" style="width: 100%; height: 100%; z-index: -1; position: fixed; top: 0px; left: 0px; border: 1px solid #00f; ">
</iframe>
var iframe = document.getElementById('iframe_3d');
iframe.src = model.ref;
src changes but no data refresh occurs, the previous site is still open in the iframe
What to do?
Thank you in advance!
Try update the element using key attribute:
<template>
<!-- ... -->
<iframe v-show="this.$store.getters['rackStore/getIframe'].show === 'iframe'" ref="iframe_3d" :src="this.$store.getters['rackStore/getIframe'].ref" id="iframe_3d" allowfullscreen="true" style="width: 100%; height: 100%; z-index: -1; position: fixed; top: 0px; left: 0px; border: 1px solid #00f; " :key="iframeUpdate"></iframe>
<!-- ... -->
</template>
<script>
export default {
// ...
data() {
return {
iframeUpdate: false
}
},
}
</script>
When your value in Vuex changes, simultaneously change iframeUpdate variable value like this:
this.iframeUpdate = !this.iframeUpdate;

Crop bottom HTML5 video

I have a shopify shop where I want to have a video banner.
I managed to set it up like the code below.
It shows up on the site and works well but I want to reduce the height of the video because it is really big. But when I adjust the height and set the video height to 75% then the bottom part of the video is not showing. It is just cut off the video.
Can I adjust the height while the video is showing the full video but rescaled?
I tried a lot of things found on internet but none worked for me. Can someone help me please?
Thanks.
Best regards,
Kevin
Liquid/HTML
{% if template.name == "index" %}
<div class="top2">
<div class="wrapper2">
<video autoplay loop muted playsinline>
<source src="https://cdn.shopify.com/s/files/1/0093/6552/0444/files/Smilezz.Promovideo.2019.Bannervideo2.1080p.mp4?4182" type="video/mp4">
</video>
</div>
</div>
{% endif %}
CSS
.top2 {
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
position: relative;
display: block;
font-size: 0;
}
.wrapper2 {
position: relative;
padding-bottom: 200%;
transform: translateY(-35.95%);
margin-bottom: -200px;
font-size: 0;
}
video {
position: absolute;
top: 0;
left: 0;
width:100%;
height: 85%;
display: block;
padding: 0;
}
The video simply needs to keep aspect ratio, otherwise the video will be cutted either vertically or horizontally.
The best approach is to control the width of video, and the height will scale automatically
Your edited CSS:
.top2 {
display: block;
/* example width - can use '%' as well */
width: 300px;
}
.wrapper2 {
position: relative;
padding-bottom: 56.25%;
height: 0;
}
video {
position: absolute;
top: 0;
left: 0;
width:100%;
height: 100%;
}

Vue I want an image to follow the mouse

I am having trouble with a Vue component https://jsfiddle.net/shawnswebsites/fep1p02c/20/. I have a div in the component and when the user's mouse enters the div I want an image to be shown and I want the image to follow the mouse.
new Vue({
el: '#app',
data: {
showImage: false,
page: {
left : 0,
top: 0
},
},
methods: {
onMouseMove(e) {
console.log('page x: ' + this.page.left);
this.page.left = e.pageX;
this.page.top = e.pageY;
}
}
})
.container {
height: 400px;
width: 400px;
border: 1px solid #FFF;
background-color: grey;
margin: 40px;
}
.image {
position: absolute;
z-index: 1000;
overflow:hidden;
}
<script src="https://unpkg.com/vue"></script>
<div id="app">
<div class="container"
#mouseenter="showImage = true"
#mousemove.self="onMouseMove($event)"
#mouseleave="showImage = false">
</div>
<img v-show="showImage" class="image" src="http://via.placeholder.com/350x150" :style="{ left: page.left + 'px', top: page.top + 'px' }">
</div>
I use a #mouseenter to show the image and #mouseleave to hide the image. However, #mouseleave is still being called as I scroll over the div, which is causing the image to blink on and off. Can any help?
As said Oxcarga in the comment below you need to add pointer-events: none; to your image style:
.image {
position: absolute;
z-index: 1000;
overflow:hidden;
pointer-events: none;
}

Slider doesn't autostart in Explorer 11

I have been unable to get this code to work on IE11 - it works fine on Chrome and Firefox, Android Chrome, Opera, just not IE. In IE11, I can actually see the images pile in on top of one another until it reaches the last image, then it just stops. The last image is distorted (as if $FillMode is set to 0). However, while clicking on the image makes no difference, dragging it even the slightest amount triggers it into operation. It's as if the auto-start is ignored, but once nudged, the function works. If I do nothing, it sits on the last image loaded indefinitely.
The head:
<script type="text/javascript" src="css/jssor.slider.js"></script>
<script async>
jQuery(document).ready(function ($) {
var _SlideshowTransitions = [{$Duration:700,$Opacity:2,$Brother:{$Duration:1000,$Opacity:2}} ];
var _CaptionTransitions = [];
var startImgNumber =Math.floor((Math.random()*16)+1);
var options = {
$CaptionSliderOptions: {
$Class: $JssorCaptionSlider$,
$CaptionTransitions: _CaptionTransitions,
$PlayInMode: 1,
$PlayOutMode: 3},
$AutoPlay: true,
$DragOrientation: 1,
$AutoPlayInterval: 5000, // ADJUST!!!!
$FillMode: 1,
$SlideHeight: 260,
//$PauseOnHover: 0,
$StartIndex: startImgNumber,
$SlideshowOptions: {
$Class: $JssorSlideshowRunner$,
$Transitions: _SlideshowTransitions,
$TransitionsOrder: 1,
$ShowLink: true
}
};
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
function ScaleSlider() {
var parentWidth = $('#slider1_container').parent().width();
if (parentWidth) {
jssor_slider1.$ScaleWidth(parentWidth);
}
else
window.setTimeout(ScaleSlider, 30);
}
//Scale slider after document ready
ScaleSlider();
//Scale slider while window load/resize/orientationchange.
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end
});
</script>
HTML code is:
<div id="PhotoShow" >
<div id="slider1_container" style="position: relative; top: 0px; left: 0px width: 332px; height: 260px; ">
<!-- Slides Container -->
<div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 330px; height: 260px; overflow: hidden;">
<div><img data-u="image" src="photos/pic1.jpg" title="Photo By me ©2015" alt=""/><div u="caption" t="transition_name1" style="position: absolute; top: 245px; left: 100px; width: 200px;height: 30px; color:#FFFBF0; font-size:x-small" >Courtesy of me © 2015</div></div>
<div><img data-u="image" src="photos/pic2.jpg" title="Photo By me ©2015"alt=""/><div u="caption" t="transition_name1" style="position: absolute; top: 245px; left: 125px; width: 200px;height: 30px; color:#ffffff; font-size:x-small" >me © 2015</div></div>
.
.
. 16 images total
</div>
</div>
</div>
(Possible I have extra /div tags - that is not the issue, just a typo), I am completely at a loss as to why this works on everything except IE11. It appears that the function simply does not execute. I've tried window.onload and a few other things - changes nothing.
Thanks for any clues or suggestions
A semicolon is missing in your html code.
Please replace
<div id="slider1_container" style="position: relative; top: 0px; left: 0px width: 332px; height: 260px; ">
with
<div id="slider1_container" style="position: relative; top: 0px; left: 0px; width: 332px; height: 260px; ">

Creating page headers and footers using CSS for print

I'm creating a PDF using Flying Saucer (which dumps out CSS/HTML to iText to a PDF) and I'm trying to use CSS3 to apply an image header and footer to each page.
I'd essentially like to put this div in the top left of each page:
<div id="pageHeader">
<img src="..." width="250" height="25"/>
</div>
My CSS looks somewhat like this:
#page {
size: 8.5in 11in;
margin: 0.5in;
#top-left {
content: "Hello";
}
}
Is there a way for me to put this div in the content?
Putting an element to the top of each page:
#page {
#top-center {
content: element(pageHeader);
}
}
#pageHeader{
position: running(pageHeader);
}
See http://www.w3.org/TR/css3-gcpm/#running-elements (works in Flying Saucer)
To include both header and footer on pages (elaborating on excellent answer from #Adam):
<style>
#page {
margin: 100px 25px;
size: letter portrait;
#top-left {
content: element(pageHeader);
}
#bottom-left {
content: element(pageFooter);
}
}
#pageHeader{
position: running(pageHeader);
}
#pageFooter{
position: running(pageFooter);
}
</style>
<body>
<header id="pageHeader">something from above</header>
<footer id="pageFooter">lurking below</footer>
<div>meaningful rambling...</div>
</body>
NOTE: In order for footer to repeat on every page it may be necessary to define it BEFORE other body content (for multi-page content)
I spent a lot of time to get this working on modern Chrome, Firefox and Safari. I use this to create a PDF from HTML. You will get header and footer fixed to each page without overlapping the page content. Try it:
CSS
<style>
#page {
margin: 10mm;
}
body {
font: 9pt sans-serif;
line-height: 1.3;
/* Avoid fixed header and footer to overlap page content */
margin-top: 100px;
margin-bottom: 50px;
}
#header {
position: fixed;
top: 0;
width: 100%;
height: 100px;
/* For testing */
background: yellow;
opacity: 0.5;
}
#footer {
position: fixed;
bottom: 0;
width: 100%;
height: 50px;
font-size: 6pt;
color: #777;
/* For testing */
background: red;
opacity: 0.5;
}
/* Print progressive page numbers */
.page-number:before {
/* counter-increment: page; */
content: "Page: " counter(page);
}
</style>
HTML
<body>
<header id="header">Header</header>
<footer id="footer">footer</footer>
<div id="content">
Here your long long content...
<p style="page-break-inside: avoid;">This text will not be broken between the pages</p>
</div>
</body>