Function for embedding "this" streamer "if" live?

Hello,

I’m creating a Twitch.tv app and what it basically does is allow you search for your favorite streamers, find out there info(live, followers, etc) then add them to your list of favorite streamers. In the users dashboard has all of the users saved streamers and each one has a button that you can click on to open up a bootstrap modal with an embedded twitch.tv stream. Right now I’m looking at the documentation for embedding live streams into websites and I believe this to be possible. I basically want to write a function that will pass whatever streamer’s button was clicked to open up the embedded twitch stream.

I have an ajax call that receives the first 10 users within the search and is able to grab all their Twitch ID’s like so:

My first guess is that I’ll have to write a function with multiple arguments that pass through and the function will have to be triggered by the button being clicked. But I’m still fairly new to JavaScript so I could use some direction on how to go about this. Thanks for any input!

I could give you a PHP example:

This is the live example: http://twitch.apiexampl.es/topOfGame.php

This is the code for that page: http://twitch.apiexampl.es/topOfGame.php.txt

It shouldn’t be difficult to mimic in JS.

1 Like

Also updated for the new embed method with overlay buttons and chat merged:

http://twitch.apiexampl.es/topOfGame-New.php.txt
http://twitch.apiexampl.es/topOfGame-New.php

source: https://dev.twitch.tv/docs/embed

1 Like

Hey Matt, thanks for the feedback! It’s different in my app though, I looked at your live example and it looks like you’re only pulling data for 1 stream. On my app you’re able to search for any streamer, add them to your list of saved streamers, then for each streamer that’s saved you’re able to click “watch stream” button and it’ll pull up their stream.

I was just showing the embed that you mentioned, of course for your function you would need to have the button that selects a specific streamer set a value to a variable that is being used in your player screen.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.