Comments (11)
I think this is roughly supported via the jsapi which will be possible to use via #20 (comment)
It'll require some experimentation though.
from lite-youtube-embed.
Wouldn't you link to the events on the main YouTube video once embedded?
I think we should expose an event when that occurs. Although a MutationObserver could possibly fill the role just fine without us needing to do any extra work. Worth looking into and explaining though.
from lite-youtube-embed.
I need this so I am implementing it in a fork now. Some thoughts:
- "enabjejsapi=1" is needed. How to implement that is trivial. I will use "videoparams=...".
- To be of any use the "onYouTubeIframeAPIReady" must be implemented since it sets up the event handlers.
- "onYouTubeIframeAPIReady" needs the iframe DOM element.
- Since the iframe element is not created until the video is played the "onYouTubeIframeAPIready" must be setup after that.
- I am adding a user defined function that will be called to do this - inside "addIframe".
Any thoughts on this?
from lite-youtube-embed.
So I implemented this. But there is a major obstacle: onYouTubeIframAPIReady
It accepts currently only a single function. That can't work in cases like this. It must accept an array (or something similar).
Is there someone who can reach the developers for that API and tell them this?
from lite-youtube-embed.
Why won't a single function work? What is the use-case where an array is required to get the expected functionality?
from lite-youtube-embed.
My use-case is a web component.
from lite-youtube-embed.
Eh, sorry, my bad. It works fine with a single function.
from lite-youtube-embed.
My use-case is a web component.
That's not a use-case, that's just what you're trying to use it in. A use case defines what your goal is, how you're approaching the problem, and what about the external API isn't allowing you to move forward.
Eh, sorry, my bad. It works fine with a single function.
So there is no need to try and get an array to be supported by the YouTube API?
from lite-youtube-embed.
So there is no need to try and get an array to be supported by the YouTube API?
No, it was my mistake. (As I guess anyone here realize you just wrap the old function in onYouTubeIframAPIReady in your new function.)
from lite-youtube-embed.
Something like this for wrapping:
`
(() => {
function myOnLoaded() {
console.warn("myOnloaded dispatch gotapi")
window.dispatchEvent(new Event("my-gotapi"));
}
async function startLoading() {
const tag = document.createElement('script');
tag.src = 'https://www.youtube.com/iframe_api';
await new Promise(function (resolve) {
if (document.readyState !== "loading") return resolve();
document.addEventListener("DOMContentLoaded", resolve);
});
document.body.append(tag);
}
if (window["YT"]) {
myOnLoaded();
return;
}
if (!window["onYouTubeIframeAPIReady"]) {
window["onYouTubeIframeAPIReady"] = myOnLoaded;
} else {
const theirOnLoaded = window["onYouTubeIframeAPIReady"];
window["onYouTubeIframeAPIReady"] = () => {
theirOnLoaded();
myOnLoaded();
}
}
startLoading();
})();
`
from lite-youtube-embed.
as of 0.1.0, you can now easily turn on the js api: https://github.com/paulirish/lite-youtube-embed#custom-player-parameters
with enablejsapi=1 ... you can then use https://developers.google.com/youtube/iframe_api_reference
from lite-youtube-embed.
Related Issues (20)
- Failed to execute 'postMessage' HOT 2
- Type declarations
- On mobile, double click is neccesary HOT 8
- Display a title on the video thumbnail HOT 2
- Graceful degradation if YT API breaks
- NPM version is outdated HOT 1
- Custom Width and Height for Youtube shorts HOT 6
- Will it be counted as views on YouTube? HOT 2
- sometime no image loaded HOT 1
- does not work on mobile HOT 2
- Early click on Progressively Enhanced version directs user to youtube.com HOT 1
- A11Y: Why `a.lty-playbtn` instead of `button`? HOT 2
- Start and end params not working when using js-api
- I am using lite youtube embed and I want to get onStateChange player.getPlayerState():
- How can we keep the lower quality preview?
- Could we get a more noob friendly guide for Pro-usage? 😇
- Deprecated navigator.vendor HOT 1
- v0.3.2 Release HOT 1
- Yield on LiteYTEmbed click listener to reduce INP impact HOT 3
- Offering the class in ESM format
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 lite-youtube-embed.