My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Live_Broadcast  
how to broadcast live chess games
Phase-Deploy, Featured
Updated Apr 23, 2012 by pa...@casaschi.net

Live games broadcast

"Always use the latest release of pgn4web; when using pgn4web for official events and for live broadcasts, read this first and don't hesitate contacting the pgn4web project for support!"
the pgn4web project

By setting the SetLiveBroadcast(delay, alertFlag, demoFlag) option in the HTML file, pgn4web will periodically refresh the PGN file, showing the live progress of the games. PGN files produced by the DGT chessboards are supported.

SetLiveBroadcast(delay, alertFlag, demoFlag, stepFlag) parameters:

  • delay = refresh interval in minutes, decimals allowed (default 1)
  • alertFlag = if set true, shows alert debug messages (default false)
  • demoFlag = if set true, sets live demo mode (default false)
  • stepFlag = if set true, autoplays updates in steps (default false)
If you set stepFlag, please note that the autoplay delay is set by SetAutoplayDelay(delay), where no more than 2000ms should be used for live broadcasts. In addition, it's recommended to disable shortcut keys and row 2 of shortcut squares in order to avoid users changing the delay value.

The bash shell script live-grab.sh, executed on your server allows for grabbing updated game source from anywhere on the Internet to your server. The live broadcast stops refreshing once all games are ended.

Clock information as provided by the DGT chessboards in PGN move comments, such as {[%clk 1:59:59]}, and in the PGN header, such as [WhiteClock "2:00:00"], [BlackClock "2:00:00"] and [Clock "W/1:59:59"] is displayed in the following sections:

<div id="GameWhiteClock"></div>
<div id="GameBlackClock"></div>

The status of the live broadcast is displayed in the following sections:

<div id="GameLiveStatus"></div>
<div id="GameLiveLastRefreshed"></div>
<div id="GameLiveLastReceived"></div>
<div id="GameLiveLastModifiedServer"></div>

Notes:

  • the GameLiveStatus will be shown as a string like 1 <> 3 meaning one live game out of three games in total, with the symbols <> and >< alternating each time the PGN source is refreshed
  • in order for the above sections to be updated properly the HTTP server hosting the live games PGN file must provide the "Last-Modified" HTTP response header to requests for the live games PGN file

Clicking on the H6 square will force a games refresh.
Clicking on the A6/B6 squares will pause/restart the automatic games refresh.

The file live-template.html shows a very basic example.

A demo facility is available to test the live broadcast functionality. If the demo flag is set in SetLiveBroadcast(delay, alertFlag, demoFlag) and a set of full games is provided, the tool will simulate a slow progress of the game. Set the proper flag in live-template.html for an example. Please note, even during a demo, the PGN file is actually refreshed from the server for a more accurate testing.
Alternatively, for a more realistic simulation, the bash shell script live-simulation.sh slowly updates the live.pgn file, simulating a real event.

The easiest way to setup a live broadcast is to use the live-compact.html file. The HTML file accepts these parameters:

  • pgnData = PGN file to load (default live.pgn)
  • initialGame = initial game to load, a number or first, last, random (default 1)
  • refreshMinutes = refresh interval in minutes, decimals allowed (default 1)
  • showComments = true | false (default false)
  • refreshDemo = true | false, sets live demo mode (default false)
For instance, make sure that the file myGames.pgn on your server is periodically refreshed with the live games, then add the following iframe to your page:

<iframe frameborder=0 width=480 height=360 src=live-compact.html?pgnData=myGames.pgn>
</iframe>

Please refrain from using a value for refreshMinutes shorter than 1 minute; a more frequent refresh does not serve any real purpose and shorter values can impact the performance of the live broadcast; values shorter than 1 minutes are allowed but intended only for demo purposes.

Of course live-compact.html can be edited to customize colors, layout and every detail.

The live-mosaic-viewer.html file has been designed in a similar way, while offering a layout with multiple live boards on the same page.

http://pgn4web-live.casaschi.net will occasionally broadcast live major chess events.

See below a demo simulation of the live broadcasting functionality. In this example the board is updated every 15 seconds and a random number of new moves (from 0 to 3) is added to each game at every update.
Please note the size of the live broadcast demo page is optimized for small displays as with smartphones; for instance, it works nicely on my Blackberry 8900 with a 480x360 screen, but be careful with wireless data usage due to the constant refresh of the PGN games.

While live-compact.html provides a very sophisticated user interface for live games broadcast, the board widget can be used as well for this purpose, as shown for example in this board widget live demo. Using the board widget the look and feel of the chessboard can be modified much easier than when using live-compact.html.

Similary, the dynamic frame can also be used for live game broadcast, especially for fullscreen applications as shown for example in this live fullscreen demo.

example: singe board

example: multiple boards


Sign in to add a comment
Powered by Google Project Hosting