I’m working on a project where I need to embed multiple video streams from a streaming platform on my webpage. Instead of loading all streams at once (which would use too much bandwidth), I want to display one player and use JavaScript buttons to switch between different streamers.
I’ve written some code but it’s not working properly. Here’s my HTML setup:
The main issue here is that you’re trying to use Flash-based Twitch embeds which are completely obsolete. Flash was discontinued years ago and modern browsers don’t support it anymore. You need to switch to Twitch’s current iframe embedding method or their JavaScript SDK. For a quick fix, replace your object tag with an iframe and modify your switching functions accordingly. Something like <iframe src="https://player.twitch.tv/?channel=streamer1&parent=yourdomain.com" frameborder="0"></iframe> and then use iframe.src = "https://player.twitch.tv/?channel=streamer2&parent=yourdomain.com" in your JavaScript functions. I ran into this exact problem when updating an old streaming site last year. The iframe approach works much better and is more reliable across different browsers. Just make sure to include your actual domain in the parent parameter or Twitch will block the embed for security reasons.
Beyond the Flash deprecation issue, there’s another fundamental problem with your approach. Even if you update the attributes correctly, Flash objects don’t refresh their content when you modify the data parameter dynamically. The Flash player loads once and maintains its internal state regardless of DOM changes. I discovered this when working on a similar multi-stream interface about three years ago. Your setAttribute calls are technically correct but Flash simply ignores them after initial load. You’d need to completely remove the object element from the DOM and recreate it with new parameters, which causes noticeable loading delays and interrupts the user experience. Modern HTML5 video elements or iframe embeds handle dynamic source changes much more gracefully since they’re designed for this kind of interaction. The iframe solution mentioned above is definitely your best path forward for seamless stream switching.
honestly your code looks fine syntax-wise but flash objects just dont reload like that. tried something similar few months back and had to completly recreate the whole object element each time which was janky af. maybe try removing the entire object with removeChild() then creating a new one with the updated channel? but seriously just switch to iframe embeds, way easier and actually works in 2024 lol