I am in the process of building my own portfolio site. I am using Ruby Sinatra. I want my home page to have a full screen video background. I have googled and I found nothing in regards to my situation. I have spent hours trying to make my video play and I have ran out of hope. I am open to any possible solutions that would help make it a success. Thanks!
HTML
<video width='512' height='288' id="splashvid" autoplay loop muted>
<source src="https://www.dropbox.com/s/2vyfy2ma6xslbyk/sweeping_view.mp4" type="video/mp4">
<source src="https://www.dropbox.com/s/svw8jyfx6a2k83n/sweeping_view.ogv" type="video/ogg">
<source src="https://www.dropbox.com/s/r99qulve4g0y4kk/sweeping_view.webm" type="video/webm">
</video>
CSS
video#splashvid {
background:url('https://www.dropbox.com/s/2vyfy2ma6xslbyk/sweeping_view.mp4') no-repeat;
-webkit-background-size:cover;
overflow: hidden;
}
First of all I'm not sure if that's a good idea, but you can do it.
Same domain
So your first problem is that you trying to load your videos from dropbox.
Accordingly to my observations in Firefox and Chrome it works only if the video source comes from the same domain. (source)
To achieve this I would create a folder called video in your public folder and link them like this: <source src="/video/sweeping_view.mp4" type="video/mp4">
Fix the autoloop
Now the video should play in most modern browser.
That loop works reliable in Firefox an Chrome I added preload="none" (source)
Fullscreen
To get the video as full screen here are a few ideas. I used
video {
width: 100% !important;
height: auto !important;
}
Which works but produces not the best results. Maybe look for a js solution.
Put html on top
And now you can place your other html elements on top of it with absolut positioning like this:
h1 {
position: absolute;
top:50px;
left: 30px;
}
Result
Related
I'm trying to auto-run, un-downloadable, muted-video in the loop, on my website, I already have visited multiple relevant and similar queries here and around but none of the fixes worked for me especially for Safari, chrome is playing well. I have my HTML as
Tags in the code below I have already tried
<video oncontextmenu="return false;" width="100%" height="50%" autoplay loop muted playsinline controlsList="nodownload" name="media">
<source src="images/portfolio/modals/work/Bookflip.mp4" type="video/mp4;codecs=avc1.42E01E, mp4a.40.2">
<p>Your browser does not support HTML5 video.</p>
</video>
Chrome is working alright, Safari is not. I'm using Safari 12.0.2
Have you tried being less specific with the type value? i.e. using type="video/mp4" instead? This is only giving a hint to the browser of course but being so specific may cause it to not work.
Also what in particular is not working? The video doesn't play at all? The auto playing isn't working? The looping?
Should both of these code blocks be used?
Should only one code block be used? If so, which one?
code per video.js
<video
id="my-player"
class="video-js"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png"
data-setup='{}'>
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4"></source>
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm"></source>
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg"></source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">
supports HTML5 video
</a>
</p>
</video>
code per amp-video-iframe
function onAmpIntegrationReady(ampIntegration) {
var myVideo = document.querySelector('#my-video');
ampIntegration.listenTo('videojs', myVideo);
}
amp-video-iframe is not supported by amp-story. The supported tags, depend on what type of layer you are using, but for amp-story-grid-layer they can be found here. Notably, if you are looking to play video, amp-video is currently the only way to do it. Since amp-video-iframe supports AMP's video interface, you can see this GitHub issue to track the implementation/support for this feature.
But, to answer your question (as it is relevant for AMP pages that are not stories): both snippets are necessary. The first code snippet adds the video to the page, while the second code snippet listens for events like play and pause to communicate them back and forth to the AMP runtime. Note that you'll need to make sure that the IDs are the same (in the code you've posted, the HTML refers to the video by the ID my-player, while the JS refers to the video by the ID my-video).
As title, my website is using html 5 video videojs.com to play video.
It works fine in chrome, fire fox. But it does not auto play when I use other tab.
I don't understand when you say "when I use other tab", however if you wish to auto play you have to use the attribute autoplay like this:
<video id='last' class='video-js vjs-default-skin' controls preload='metadata' autoplay > <source src='../videos/P04A.mp4' type='video/mp4'> <source src='http://video-js.zencoder.com/oceans-clip.webm' type='video/webm'>
PS: I post as a response because I can't comment (you know reputation and all...), but I will edit as soon as you specify
I'm using video.js with mp4 files, it works fine in chrome, but only runs properly on every other video (even ones, not odd ones)
My code is formatted like this
<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/c/video.js"></script>
<video id="video_1" class="video-js vjs-default-skin" controls data-setup="{}" width="580" height="317">
<source src="/path/to/file.mov" type="video/mp4">
Video tag not supported.
</video>
Making the video an absolute link does not work, self closing or normal closing of the source tag does not work, removing "Video tag not supported." does not work. The only work around I have right now is to load an empty video tag before each actual video and then hide it with css.
The videos that fail to load have a div with the same attributes as my video tag, a fluid-width-video-rapper div inside that, and a swf object, but none of the vjs divs
I'm trying to embed a Vimeo video and force it to use HTML5 by default.
Here's a thread about doing the same thing I'm tying to do but with YouTube.
Here's another thread talking about getting the Vimeo HTML5 cookie
Here's a discussion of the issue on Vimeo's site. Basically, I would be doing it in response to a user's preference on my site so their concerns don't really apply.
Does anyone know a workaround or way to force HTML5 Vimeo embeds even when Flash is available? (I know the cookie should work in Safari but I have many Chrome users.)
Thanks.
Currently there is no way to force HTML5 with the embed script. The "universal player" automatically chooses the format based on the device.
The old embed provides a way to force Flash, but that's the only other option.
Let's hope for the option in the future.
On a browser with flash the player loads in html5 mode with the following code. The sandbox prevents the iframe from accessing any plugins including flash.
<iframe sandbox="allow-same-origin allow-scripts allow-popups"
id="foo" width="100%" height="90%"
allowfullscreen="" webkitallowfullscreen="" mozallowfullscreen=""
src="http://player.vimeo.com/video/28544156?api=1">
</iframe>
To allow the vimeo button to open the vimeo web page for the video you need the 'allow-popups' permission. It's not needed to play the video.
Edit: adding complete example
If you had just a black view it's possible that the video had a size of zero because I had the iframe set to fill parent with width 100%, but if the parent was shrink to fit then that size would still be zero. Here is a whole web page with the CSS to make the video fill up most of the page. Additionally the -webkit-transform will mirror image the video, and then rotate it slightly. If it was displaying in flash this would produce a black screen as it can't handle rotations at all. I have since found out that this probably won't work on firefox at all because it doesn't natively support h.264 which is all vimeo serves, and disabling plugins will disable whatever plugin is making h.264 work on firefox.
<!DOCTYPE html>
<html>
<head>
<style>
div {
display: inline-block;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
position: absolute;
}
iframe {
-webkit-transform: scaleX(-1) rotate(2deg);
}
</style>
</head>
<body>
<div>
<iframe sandbox="allow-same-origin allow-scripts allow-popups"
id="foo" width="100%" height="90%"
allowfullscreen="" webkitallowfullscreen="" mozallowfullscreen=""
src="http://player.vimeo.com/video/28544156?api=1">
</iframe>
</div>
</body>
</html>