ROOKIE ALERT (Learning HTML5/ JavaScript/ CSS from a book): why won't my video file load and play in Firefox (using Win 8, avi/wmv files)? - html5-video

I get the video control panel but there's no video loaded in the browser. Tried mp3, as well. Coded as follows:
video {
width: 15%; height: auto; float: right; padding: 1rem;
}
<body>
<video controls>
<source src="images/Manny4.wmv" type="video/x-ms-wmv">
</video>
</body>

Firefox and other browsers do not support WMV videos. https://support.mozilla.org/en-US/kb/html5-audio-and-video-firefox

Converted file to webm format and it worked, therefore, i accept it as a solution. I'm still trying to learn protocols; I will do better in the future.

Related

How to set a Video Background in ASP .NetCore MVC Web Application

Currently, I am working on a ASP .NetCore project to make a web application. I face trouble in setting a video background for the entire application. There are plenty of methods to set a video background for ordinary Html/CSS projects but I was unable to find a reliable method to set up a video background for a ASP.net core MVC web application.
Project Details:
Framework: ASP .NetCore MVC web application
Target Framework: net 5.0
This is my project structure:The folder structure of the MVC web app
I was in a hurry to find a way to do this. I am sorry if the information provided by me are not sufficient. Yes, I have tried using simple available methods such as,
Using video tag in _layout.cshtml file as follows.
HTML code:
<div class="fullscreen-bg">
<video loop muted autoplay poster="images/background.jpg" class="fullscreen-bg__video">
<source src="../../wwwroot/video/background.mp4" type="video/mp4">
</video>
</div>
CSS code:
.fullscreen-bg {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
z-index: -100;
}
.fullscreen-bg__video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
The video file is saved in images folder of wwwroot folder. It is a mp4 file.
I have tried several codes similar to above code, but it does not work in ASP.NETcore web app.
I ran into a similar problem, once. This could be solved by few codes added to the _layout.cshtml. Following is the method I followed to solve the issue. I hope this might help you to solve your issue, too.
I made the following changes in the _layout.cshtml file.
In _layout.cshtml you can find the following code snippet:
<div class="container">
<main role="main" class="pb-3">
#RenderBody()
</main>
</div>
Modify it as follows:
<div class="container embed-responsive">
<main role="main">
<div>
<video autoplay muted loop poster="">
<source src="" data-src="https://webtests.blob.core.windows.net/samplevideo/background.mp4" type="video/mp4">
</video>
<div class="container">
#RenderBody()
</div>
</div>
</main>
</div>
In the 'body' tag, add the bootstrap classes 'jumbotron' and 'jumbotron-fluid' as follows.
<body class="jumbotron-fluid jumbotron">
In the 'nav' tag, add the bootstrap class 'fixed-top' as follows (otherwise navbar is hidden under the layers and not clickable):
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3 fixed-top">
Now, after the </html> tag at the end, add the following script.
<script>
function backgroundVideo() {
$("video source").each(function () {
var sourceFile = $(this).attr("data-src");
$(this).attr("src", sourceFile);
var video = this.parentElement;
video.load();
});
}
window.onload = backgroundVideo;
</script>
Next modify the bootstrap classes as follows. You may change the properties of the classes until the desired output is obtained.
<style>
.jumbotron {
background-color: #454545;
}
.jumbotron .hero-section {
position: fixed;
z-index: 1;
top: 0;
width: 100%;
height: 100%;
object-fit: cover;
opacity: 0.6;
background: black;
}
.jumbotron .container {
z-index: 2;
position: relative;
}
</style>
If you may wonder how I get the 'data-src' URL for the video. It is very easy. Follow the steps below.
Create an Azure account for free. (you can use your university mail/GitHub student package or just use the credit card number)
Search for 'Azure blob storage' and create a 'container' with public access enabled. (This can be done when creating the container)
screenshot
Next upload the video file to blob storage and get the URL. screenshot
Now you can use that URL directly in the project.
You can further decrease the video file size using this online converter without affecting the quality: https://www.freeconvert.com/video-compressor
You can get the added benefit that your project size becomes less since the heavy media files are stored in the cloud.
This solved my problem. I hope you may use it wisely. Please feel free to suggest more. I am also learning and highly value your opinion.
I think it is the path problem, wwwroot is a web root path when you run it. So the path need to be changed as:
<source src="~/video/background.mp4" type="video/mp4">
Edit:
It is possible that browser has compatibility issues with the transcoded video. You can also use videojs.
<div>
<video id="my-video" class="video-js" controls preload="auto" width="1296" height="728"
poster="video/cover.png" data-setup="{}">
<source src="~/images/1.mp4" type="video/mp4" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
supports HTML5 video
</p>
</video>
</div>
#section Scripts{
<link href="//vjs.zencdn.net/7.10.2/video-js.min.css" rel="stylesheet">
<script src="//vjs.zencdn.net/7.10.2/video.min.js"></script>
#*If you'd like to support IE8*#
#*<script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"> </script>*#
<script>
var my_video = videojs('my-video');
videojs('my-video').ready(function () {
var myvideo = this;
myvideo.play();
});
</script>
}

HTML5 Video Background and Safari Not Playing Nice

Running into an issue with safari. For some reason, the footer is disappearing under the video until you hover over where it should be. Once you do that it pops into place and works normally. In order to replicate it, have the footer out of view, and reload the page, or click into a backpage and click back to home.
Tested on multiple Macs (MacPro using 1080p monitor, Macbook Air, and Macbook Pro) using all browsers, and the video works fine in Opera, Chrome, Firefox, even IE (parallels) but not safari. Windows machines have no issues using all browsers Chrome, Firefox, Opera, and IE.
The video background is being built onto a WordPress site using underscores as the base for the theme that I'm building.
The below URL is whats giving me fits.
http://yokellocalhosting.com/freddy/
Here is how I have the background setup in the HTML:
<?php if(is_front_page() ) { ?>
<div id="videoContainer">
<video autoplay loop id="videoBackground" preload="auto">
<source src="http://yokellocalhosting.com/freddy/wp-content/uploads/2014/03/Fabulous_Freddys_Background_MP4.mp4" type="video/mp4" />
<source src="http://yokellocalhosting.com/freddy/wp-content/uploads/2014/03/Fabulous_Freddys_Background_OGG.ogg" type="video/ogg" />
<source src="http://yokellocalhosting.com/freddy/wp-content/uploads/2014/03/Fabulous_Freddys_Background_WEBM.webm" type="video/webm" />
</video>
</div>
<?php } ?>
Here is the associated CSS:
#videoContainer{
position: fixed;
left: 0px;
top: 0px;
z-index: 9;
width: 100%;
height: 100%;
}
#videoBackground{
position: relative;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: 9;
}
I know I have the MIME types for the server setup correctly. Just can't figure out what the issue is and why its doing what its doing.

Howto place the start button in the middle of the clip

I found the designer page on http://www.videojs.com/ there you can change the position of the start button to be in the middle of your clips.
But I am not able to place or use this stylesheets on the video.js player. Could some one explain how to use it in the player. E. G. to extend the existing css with an extra file? or how to change the existing css to place the button not on the left top but in the middle?
Thanks. Katasun
You can add 'vjs-big-play-centered' to video class.
<video id="player" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="700" height="450" poster="http://www.videojs.com/img/poster.jpg"><source src="" type="video/mp4"></video>
Using version 4.1.0:
In video-js.css, in .vjs-default-skin .vjs-big-play-button (line 484+) replace:
top: 2em;
left: 2em;
margin: 0;
with:
top: 50%;
left: 50%;
margin-left: -6em;
margin-top: -4em;
-6em and -4em because the width is 12em and height is 8em
Just had the same problem and had to fix it this way :) Works on the latest chrome, firefox, safari and opera, didn't test on IE, i'm on OSX
I have amended a version of videojs where you can place the play button anywhere. This also means being able to touch the thumbnail anyway on IOS devices (doesn't have to be the center) and it will run the video. http://www.andy-howard.com/recreate-bbc-iplayer/index.html

ipad object scrollbar

first timer here. I help manage a WordPress site that has an html object imbedded in a div that overflows. The scrollbar functionality works fine on pc's; however, on an ipad (and I assume an iphone and android devices), the scrollbar doesn't appear. The html I have is:
#wrapper {
width:100%;
height:360px;
overflow:scroll;
-webkit-overflow-scrolling:touch;
}
#wrapper object {
width: 100%;
height: 100%;
}
<div id="wrapper">
<object id="object" type="text/html" data="[link to html page with lots of <tr> rows]"
</object>
</div>
I'm wondering if perhaps the webkit overflow attribute should be on the object instead of the div to get this to work correctly?

How to implement a responsive Youtube embed iframe with Twitter Bootstrap?

Currently I'm embedding Youtube videos with the following HAML code in a Twitter Bootstrap based site:
.row
.span12
%iframe.span11{ :height => "720", :frameborder => "0", :allowfullscreen => nil, :src => v.video_url }
Unfortunately, this doesn't respond well when resizing the browser or on mobile devices because of the static height.
What would be a better (more dynamic and responsive) way to implement this embedded iframe for Youtube?
Try this "Responsive video CSS", it works perfect for me: https://gist.github.com/2302238
<section class="row">
<div class="span6">
<div class="flex-video widescreen"><iframe src="https://www.youtube-nocookie.com/embed/..." frameborder="0" allowfullscreen=""></iframe></div>
</div>
<div class="span6">
...
</div>
</section>
I implemented a pure CSS solution which works great.
Here is an example of code in my view using the iframe code generated in YouTube.
<div class="video-container">
<iframe width="300" height="168" src="http://www.youtube.com/embed/MY__5O1i2a0" frameborder="0" allowfullscreen></iframe>
</div>
Here is an example of code in another view where instead of using iframe I used the body field generated from the AutoHtml gem, which is used for embedding different types of video links into a web page. This is good if you have a model where a link needs to be dynamically embedded into the same web page.
<div class="video-container">
<span style="text-align: center;"><%= #livevideo.body_html %></span>
</div>
Here is the CSS code:
.video-container {
position: relative; /* keeps the aspect ratio */
padding-bottom: 56.25%; /* fine tunes the video positioning */
padding-top: 60px; overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
Here is the YouTube video which explains in great detail how the code works and give one or two blog posts to check out.
http://www.youtube.com/watch?v=PL_R3zEjqEc
Bootstrap 3.2.0 comes with a several improvements and a large number of bug fixes. A framework for building websites with a responsive design, Bootstrap was missing support for responsive , and elements, feature added in this latest version.
The HTML for a responsive YouTube 16:9 video that adjusts its size based on the width of the page it is displayed in looks like this:
On your container(maybe DIV) add class="embed-responsive embed-responsive-16by9"
This is probably best done with jQuery: http://www.seanmccambridge.com/tubular/ or http://okfoc.us/okvideo/
Just to automatize #Bart's answer, I've created a simple Javascript snipped that automatically wraps iframe elements within <div class="flex-video">
$(document).ready(function() {
$('iframe').each(function() {
$(this).wrap('<div class="flex-video"></div>');
});
});
If using bootstrap, the method below is without a doubt the easiest way to implement a responsive embed:
<!-- 16:9 aspect ratio -->
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="..."></iframe>
</div>
<!-- 4:3 aspect ratio -->
<div class="embed-responsive embed-responsive-4by3">
<iframe class="embed-responsive-item" src="..."></iframe>
</div>
Documentation can be found here: http://getbootstrap.com/components/#responsive-embed.