How to achieve the same effect when it comes to background video? - javascript

H!
I have to achieve the same effect with background video in "hero" section (first below navbar) as on the given page: https://www.invisionapp.com/. Do yo have any idea what I could use if I have video in mp4 format? And also it should behave the same way as on the page - plays in full screen modal when click "play" button. Any video service provider, javascript library recommended?
Thanks in advance!
Best regards!

About the background video you could you a video tag with a z-level in css.
The z-level will put it a layer below whats above.
For example:
<video autoplay loop muted style="z-index: -1;">
<source src="video.mp4" type="video/mp4">
</video>
But I am not sure how to implement the full screen modal, unfortunately.

Related

html5 video: once the video is loaded, a flash is appeared. how to remove it?

I am using html5 and while the video is downloading I am using a fallback image in poster attribute. but the problem is once the video is downloaded a flashy screen is showing for a short period of time. how can I remove this, so that the flash will not visible?
<video class="bg-video" loop="" muted="" autoplay="" playsinline="" poster="https://i3.ytimg.com/vi/Zs0bsagDzw8/maxresdefault.jpg">
<source />
</video>
live site:
https://nordic.dnscheck.io/
If you mean the black frame, it's in your video so you should edit it out from there.
If you really can't edit that file anymore you can still kind of workaround that by using the media fragment syntax and make your video automatically seek to after that black frame:
<video muted loop autoplay
poster="https://nordic.dnscheck.io/bilder/poster.webp"
src="https://nordic.dnscheck.io/nordic.webm#t=0.8"
></video>
However beware that the black frame will still be here at the next loop.
Also, while it's not an issue for you since you do autoplay the video, one should note that (currently) setting the seeking time through the media fragment syntax will disable the poster once the video has loaded.

How to control any embedded video?

I scraped some videos, and displayed them with iframes. That works well, however, I am now looking for a way to control these videos on my react app.
What i mean by control is for instance: pause, play, currentTime in video...etc.
I have tried several things so far.
html5 tags, but it does not work mp4 video link that I have.
A few packages, like jplayer or player.js.
I am pretty sure I can achieve my goal, I guess I just need to find the right tool.
EDIT: Here is a example of my code with video.js
<video
id="my-player"
class="video-js"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png"
data-setup='{}'>
<source src="https://openload.co/embed/myvideo" type="video/mp4"></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>
Take a look at video.js. It will give you a complete control over your video playback. Take a look at their advanced examples.
Also, you don't need iframes to work with videos. If that is a design decision then it's fine but you can do video embeds without iframes.
To control video player instance via js refer to following
JS
var myPlayer = videojs('example_video_1');
HTML
<video id="example_video_1" data-setup="{}" controls="">
<source src="my-source.mp4" type="video/mp4">
</video>
Then you can control the player instance like following
myPlayer.play();
myPlayer.pause();
myPlayer.currentTime(120);
Please look at the player API in the following link
https://docs.videojs.com/docs/api/player.html
Please look at react component implementation in the following link
https://docs.videojs.com/tutorial-react.html

how to set html5 video tag source from css

Anyone with html css expertise help me out with this simple problem that I am unable to solve.
Basically, my html page has a video element which has a src attribute attached to it.
Now, what i want to do is, remove this src attribute from the video element and put this source in the css class of that video element.
So, how can I set the src of the video element from css?
I have tried using url,content attributes but it does not seem to work.
Or maybe i am doing it wrong.
i would be grateful to anyone who could provide any input for this or share a small code which would use css to set the source of an html5 video element.
please help me.
Thank you.
You cannot set the video source via CSS.
Because you see below the basic structure of video:
<video>
<source src="sample.mp4" type="video/mp4">
<source src="sample.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
You can set other attributes like background image, color, etc. However, you cannot set the source via css, which is used to design the play button & any other button functions.
If you really need to do this without using <source src="sample.mp4" type="video/mp4"></source>, you will have to use JavaScript.
I did it with CSS using the display set to none or block, so that the video ("sample.mp4" or "sample2.mp3" is played depending on whether the user is on his laptop or on his mobile.
HTML:
<video id='video'>
<source src="sample.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
<video id='video2'>
<source src="sample2.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
CSS:
#video2 {display:none;}
#media only screen and (max-width: 500px) {
#video2 {display:block;}
#video {display:none;}
}

How to add video in parallax Slider?

I have a parrallax slider, I have put just image and description on slider, and I want to add a video, this is my code:
{ <div id="da-slider" class="da-slider">
<div class="da-slide">
<h2>Vidéo PUB</h2>
<p>loading</p> <!--wanna put the video here -->
</div>
<div class="da-slide">
<h2>Affréteurs</h2>
<p></p>
<div class="da-img"><img src="" alt="" /></div>
</div> }
My problem is the video is static.
I'm currently using this slider:
Yii2 Da-Slider
I want to:
Add it to the first slide
Set it so it autoplays
After the video finishes playing I want the slider to automatically resume and move to the next slide.
How can I do this?
I would recommend setting up a YouTube account to host your video on.
If the site is popular then it offloads the strain of serving the video file over to YouTube's fast, dedicated servers.
Once you have got your YouTube video uploaded you can add it to the slide by clicking the Share button beneath the video and then clicking Embed. This will give you a snippet of code like this which you can use in your slider code above:
<iframe width="560" height="315" src="https://www.youtube.com/embed/_dJCLaoBZvM?rel=0" frameborder="0" allowfullscreen></iframe>
Notice the rel=0 on the end. That stops it suggesting other videos once yours has finished playing which makes the whole thing more professional. You can also add autoplay=1 if you want it to start playing straight away. There are also more advanced integrations that you can do where you control the chrome of the video player (the skin around the edge).
I've done this before with parallax and it comes out looking amazing.
I prefer this method to a service like Youtube or Vimeo because you have more control and be able to style it how you want more effectively.
You want to get your video in mp4 and ogg format. You can do this with VLC media player. It's free.
Then I used the html5 <video> tag (Link Here). here is a sample. You will want to style for position, etc... in your CSS.
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

AngularJS ngInclude Html5 Video doesn't get replaced

My issue: ngIncluding a video source doesn't replace the video.
My page has a feed and a preview, each time I click on a post in the the feed, its preview gets injected (ngInclude) to the preview area.
It works fine for youtube video, for images and for text but when it gets to html5 videos, the same video keeps showing and it seems the source doesn't get replaced in the page.
Weirdest thing is when I enter chrome debugger and inspect the element, I see its source gets replaced with a different url, but the video in the preview doesn't change.
I even tried enabling autoplay and when I move through posts the video continues to play on smoothly.
Here are the relevant code bits:
The preview that gets ngIncluded:
<div ng-if="postInfo.Media.type == 'video'">
<video name="media" width="582" height="582" controls autoplay>
<source src="{{postInfo.Media.videoStandardResolution}}" type="video/mp4">
</video>
</div>
The main page including bit:
<div id="preview-panel">
<ng-include src="htmlInclude" onload="responsiveCalc()"/>
</div>
And in my javascript when I get an event of post changed in the feed, I just re-initialize the $scope.htmlInclude
Anyone came across anything like it? Should I somehow refresh the video source? And if so how.
Thanks!
Try using ng-src instead of src in the video source tag
<source ng-src="{{postInfo.Media.videoStandardResolution}}" type="video/mp4">
This lets angular know that the src will be replaced and to fetch the result
What ended up solving this was removing the source tag inside the video tag and changing directly the 'src' attribute of the video.
Came across this: http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#the-source-element
and from there it was pretty obvious.
so my html now looks like this:
<video name="media" width="582" height="582" controls autoplay src="{{postInfo.Media.videoStandardResolution}}">
Your browser does not support the video tag.
</video>

Categories

Resources