Hey folks,
I’m playing around with the Twitch Embed (“Embedding Everything” in the docs) API, and so far it’s working excellently, but I think I’ve hit a snag when using event listeners for the player embedded by this API.
Here is the code I’m using:
const embed = new Twitch.Embed("target-div", {
width: "100%",
height: "100%",
channel: "argus9",
playsinline: true
});
embed.addEventListener(Twitch.Embed.VIDEO_READY, () => {
let player = embed.getPlayer();
player.setVolume(0.8); // Works
player.addEventListener(Twitch.Player.ONLINE, function () {
console.log("We are now online!");
}); // player.addEventListener is not a function
});
The docs mention that the object returned by embed.getPlayer() should follow the full video API. Am I doing something wrong?
Quick bump, hoping to see if anyone has any insight into this. The combined embed API is REALLY nice, but without player callbacks it’s severely crippled compared to a stand-alone embedded player.
After poking around with the example code in the docs and your code above in JS Bin, I can confirm this behavior as existing and being confusing.
It appears there’s a clear contradiction between what the docs claim you should be able to do with embed.getPlayer() and what’s possible in the browser:
Thanks for confirming, @offbeatlive. Good to know it’s not just me.
I was planning to try and poke around in the player code to see if there is some way to get the existing callback logic on the stand-alone player to work here, but I haven’t really had time to get into it. I’ll see if I can give it a look this weekend. Otherwise I hope we can get this to the embedded team’s attention.