MyBB Community Forums

Full Version: Twitch API
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So i implemented twitch's api i have the video and the chat
Video Code:
<object bgcolor="#000000" 
        data="//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf" 
        height="378" 
        type="application/x-shockwave-flash" 
        width="620" 
        > 
  <param name="allowFullScreen" 
          value="true" />
  <param name="allowNetworking" 
          value="all" />
  <param name="allowScriptAccess" 
          value="always" />
  <param name="movie" 
          value="//www-cdn.jtvnw.net/swflibs/TwitchPlayer.swf" />
  <param name="flashvars" 
          value="channel=Stream&auto_play={AUTO_PLAY}&start_volume={VOLUME}" />
</object>
Chat Code:
<iframe frameborder="0" 
        scrolling="no" 
        id="chat_embed" 
        src="http://www.twitch.tv/Stream/chat" 
        height="378" 
        width="620">
</iframe>
I put the code by going to my templates>theme>index Page Templates>index 
how would i make it so both the video and the chat change change streams together every 30 min? i want it to change streams to people with 15 viewers or less so they can get a boost in viewers  Big Grin also adding a drop down like this would be nice 
[Image: 6294a41d2f3f751d4dee1213da47212d.png]
You will have to set up a task which rotates the current channel id.

You might want to look into the twitch API on github:
https://github.com/justintv/twitch-api

You can check the existing mybb tasks to see how to set it up. You will have to configure it from the admin panel.

You can then create a twitch.php file with the stream and chat iframe which is included in your template via an iframe (<iframe src="twitch.php"></iframe>). This php file will get access to the current channel ID which is rotated by the task. You can save the current channel in a mybb option or directly in a file, if you do the later you will never have to connect to mybb's database which will slightly improve performance.

Alternatively if you save it as a mybb option you will be able to grab the channel ID directly from the template.

Let me know which route you want to go and I will give you more detailed instructions.

Needless to say, automatically playing a stream will be disrupting to first time visitors so you might want do disable autoplay.
I made a whole new page for it i have it set up with the stream and chat already now i just need need is for it to be switching channels every now and then automatically and to have the option to change it manually
(2015-10-03, 10:43 PM)luciferakasatan Wrote: [ -> ]I made a whole new page for it i have it set up with the stream and chat already now i just need need is for it to be switching channels every now and then automatically and to have the option to change it manually

Have you tried what I posted? Are you having problems with a specific step?
Can you tell me step by step how to do this ? I am confused on how to set it up as a Mybb option and such
Moved to Plugin Support.