inherit
249346
0
Jun 7, 2019 10:52:14 GMT -8
resisbeststat
7
September 2017
resisbeststat
|
Post by resisbeststat on Nov 17, 2017 10:39:05 GMT -8
Hey there. I've been trying to add an animated background to my site for Christmas since it's a special occasion and all that. I found a way to add said animated background (Which is in reality just a video being played in place of the background itself). However, my method utilizes the Layout Template in Forum Wrapper. Therefore, the animated background appears on all pages and not only on the main page.
This normally wouldn't be an issue, but the video I'm using has audio in it. I'm not quite sure how to add a mute button since I'm not really a competent coder. Is there a way to make it so the animated background only plays on the main page? Is it also possible to have the animated background play on all pages, but include a mute button alongside it?
The code I've been using so far is:
<video playsinline autoplay loop poster="https://puu.sh/ylgA9/b1affdc9be.png" class="backgroundVideo"> <source src="https://puu.sh/ylhMh/d5e7e3e3a3.webm" type="video/webm"> <source src="https://puu.sh/yljEx/f030566391.mp4" type="video/mp4"> </video>
directly above <div id="wrapper"> in the Forum Wrapper layout page.
The CSS is:
.backgroundVideo { background: url(https://puu.sh/ylgA9/b1affdc9be.png) no-repeat; background-size: cover; width: auto; height: auto; min-width: 100%; min-height: 100%; position: fixed; top: 0; left: 50%; z-index: -100; transform: translateX(-50%); }
Thanks in advance!
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Nov 20, 2017 6:04:10 GMT -8
Add this to the code to add mute button and controls for sound:
|
|
inherit
249346
0
Jun 7, 2019 10:52:14 GMT -8
resisbeststat
7
September 2017
resisbeststat
|
Post by resisbeststat on Nov 20, 2017 12:41:02 GMT -8
Hi and thanks for replying!
I've added controls to the code, but the mute button and sound options won't show up. I think it might be due to the video being an animated background, therefore covering the screen and leaving no space for the controls, but I'm not entirely sure. Still, mute and sound options won't show up even with controls in the code.
What should I do?
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Nov 20, 2017 13:39:33 GMT -8
Sure works on my test site. If I may ask, are you the admin of that forum and if so, you need to get this plugin for it to work: HTML In Post by Pebble You have to create a account and then download it from the link above.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Nov 21, 2017 5:44:58 GMT -8
Hello resisbeststatUpdate: I had your code in a posting page using HTML In Post by Pebble and added the [html] above that code and it worked just fine. Did as you did and placed that code in the Forum Wrapper above everything else with the controls added and sure enough, it did not work. Will tag Brian or Ulises and see if they have any input on why it is not working in your Forum Wrapper with the controls added. Other than that, I'm at a loss as to why it is not working. p.s. it I may suggest, you may want to add your forum URL in your OP post.
|
|
inherit
246669
0
Jan 2, 2023 13:25:26 GMT -8
Philip
97
July 2017
phil82
|
Post by Philip on Nov 21, 2017 14:56:22 GMT -8
First you need to set the { object-fit} CSS property, this is somewhat similar to what { background-size} does, visually. Next, you will need to change the markup as follows, inside your { forum_wrapper} template I removed the default video player controls and created a custom volume control for you. The onloadeddata event will, simply set the volume to 0.3 initially, rather than the default 1.0, headphone users will appreciate this Next, paste in the following script under the markup provided above. <script> var customControls = (function(){ var volumeRange, videoEl; var _setUpCustomControl = function(){ videoEl = document.querySelector('.backgroundVideo') volumeRange = document.getElementById('volume-control') volumeRange.value = videoEl.volume.toString() volumeRange.addEventListener('change', function(e){ var _volume = parseFloat(e.currentTarget.value) _setVolumeLevel(_volume) }) }; var _setVolumeLevel = function(volume){ videoEl.volume = volume volumeRange.value = volume.toString() }; document.addEventListener('DOMContentLoaded', _setUpCustomControl); return { setVolumeLevel: _setVolumeLevel } })(); </script>
Finally for the volume range control CSS, add the following to your stylesheet The above CSS will rotate the range slider(input[type=range]) to a vertical one, rather than a horizontal one. I hope this was helpful to you.
|
|
inherit
249346
0
Jun 7, 2019 10:52:14 GMT -8
resisbeststat
7
September 2017
resisbeststat
|
Post by resisbeststat on Nov 22, 2017 11:32:48 GMT -8
Hi phil and thanks for the help! I've tried it out and while I still see no volume slider, at least the animated background only plays on the main page. That's some progress at least. Anyways, the volume is definitely lower than usual. However, I saw no volume slider. I thought I might have pasted the code incorrectly or left something out. However, I pasted all of your code in a CodePen and it works like a charm. Must be related to the position of the code I guess. Therefore, I decided to just show you screenshots of the forum wrapper and CSS style sheet. This is the forum wrapper. I put the Javascript underneath the {/if}. Is this where it's supposed to be or not? Also, this entire piece of code is located directly above <div id="wrapper"> of an untouched Forum Wrapper. This is where I put the first CSS code. It's underneath all of the default Proboards CSS code. And this is the final CSS code which is located directly below that. By the way, this is how the background looks like on the forum itself. There is no volume slider hidden in the middle of the page or anything. I checked and checked again to no avail. This is how it looks on CodePen. The volume slider is actually a thing in here. Any reason why the forum won't show it? Do I need some sort of plugin?
|
|
inherit
246669
0
Jan 2, 2023 13:25:26 GMT -8
Philip
97
July 2017
phil82
|
Post by Philip on Nov 22, 2017 14:30:48 GMT -8
No plugin required. can you link me to your forum, to better debug ? something on your forum may be blocking it.
Cheers
|
|
inherit
249346
0
Jun 7, 2019 10:52:14 GMT -8
resisbeststat
7
September 2017
resisbeststat
|
Post by resisbeststat on Nov 28, 2017 13:01:20 GMT -8
Sorry for the late reply. Was busy for the week and almost forgot about this question lol Here's the forum link.
|
|
inherit
246669
0
Jan 2, 2023 13:25:26 GMT -8
Philip
97
July 2017
phil82
|
Post by Philip on Nov 28, 2017 13:23:31 GMT -8
Sorry for the late reply. Was busy for the week and almost forgot about this question lol Here's the forum link.Just move, <div class='volume'> outside/after the <video> tag. That should fix it.
|
|
inherit
249346
0
Jun 7, 2019 10:52:14 GMT -8
resisbeststat
7
September 2017
resisbeststat
|
Post by resisbeststat on Nov 29, 2017 8:01:15 GMT -8
It works! Thanks a lot! You can lock this thread now I guess
|
|