Created
March 4, 2010 14:25
-
-
Save fuba/321739 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="http://www-cdn.justin.tv/javascripts/jtv_api.js"></script> | |
| <div id="display"></div> | |
| <script language="javascript"> | |
| var gid = document.getElementById; | |
| var event_names = ('buffering stop_buffering buffer_full buffer_empty stream_lost'+ | |
| ' video_not_found playing_playlist_video connected started'+ | |
| ' broadcast_finished total_viewer_count stream_viewer_count').split(/ /); | |
| var events = {}; | |
| event_names.forEach( | |
| function (name) { | |
| events[name] = function (obj) { | |
| if (obj && obj.stream) { | |
| window.alert(obj.stream); | |
| } | |
| document.getElementById('message').innerHTML += name + "\n"; | |
| } | |
| } | |
| ); | |
| function create_player (channel) { | |
| return jtv_api.new_player( | |
| 'display', | |
| { | |
| 'channel': (channel) ? channel : get_channel(), | |
| 'start_volume': 0, | |
| 'watermark_position': 'bottom_right', | |
| 'custom': true, | |
| 'events': events, | |
| 'auto_play': false | |
| } | |
| ); | |
| } | |
| function get_channel () { | |
| return document.getElementById('show').value; | |
| } | |
| //document.body.appendChild(player); | |
| </script> | |
| <p> | |
| <input type="text" id="show" value="earwaxface"></input> | |
| <input type="button" onclick='player.play_live(get_channel());' value="show" /> | |
| <input type="button" onclick='player.pause_video()' value="stop" /> | |
| </p> | |
| <pre id='message'></pre> | |
| <script language="javascript"> | |
| var player = create_player(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment