Comments (4)
Thanks! I went with your second suggestion and works perfectly now. Thanks for teaching me a little bit.
from vidage.
Hello @Porco-Rosso,
The JS itself will just run the video when it's ready to play, debounce resize event, and add a class that actually alters the video(s).
Did you load the required css file?
from vidage.
Yes I added the css, and the default video works.
I guess it has something to do with the order of the scripts executing. I tried defer and module, but couldn't figure it out. I am attaching the page, it is rather simple.
porco.zip
Sorry if this out of scope for the project! Though a function to change the background video would be a cool addition.
from vidage.
Hello,
Thank you for the attachment. It's an interesting find.
However, from my experience, changing sources will do nothing, as a browser already picked one of available sources and is running it.
You can find that out like this (simply pasting in browser console will do the trick):
document.querySelector('#vidage').currentSrc
You could check currentSrc
for type of source that browser picked and based on that change the video:src
directly, like this (providing untested code below):
const vdgElement = document.querySelector('#vidage')
const srcType = vdgElement.currentSrc.slice(vdgElement.currentSrc.lastIndexOf('.') + 1)
switch (srcType) {
case 'webm':
vdgElement.src = 'path_to_webm_file_source'
break
case 'mp4':
vdgElement.src = 'path_to_mp4_file_source'
break
}
By that logic, everything should work as normal, but it's too much mess and logic IMO.
Another suggestion, which I'd prefer, is to use given vidage element and load the source again when you generate sources dynamically.
It'd look something like this in your example:
randomVideo(); // I capitalized V in Video
const vdg = new Vidage('#vidage')
vdg.element.load()
You'd simply move instance of Vidage inside or outside your function after main execution is complete, set the instance to a variable to get access to the given element and give it a
load
.
from vidage.
Related Issues (12)
- ParseError: 'import' and 'export' may appear only with 'sourceType: module' HOT 2
- Problems on Safari HOT 2
- osx safair bug HOT 4
- Sir tell me how to make a bot on telegram which can make video combine HOT 1
- It works in IE HOT 11
- Won't auto play muted video on Safari for Mac, iOS 14 for iPhone and iPad HOT 2
- Why there is no info about needed css in readme? HOT 1
- npm 0.1.3 Vidage.min.js missed HOT 4
- Play YouTube - Vimeo HOT 8
- Remove video if it is mobile device HOT 11
- QQ – Android Messanger App (China) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vidage.