Skip to content

Instantly share code, notes, and snippets.

@tommyh
Last active April 26, 2017 22:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyh/03c8395a157a1e3c9b02 to your computer and use it in GitHub Desktop.
Save tommyh/03c8395a157a1e3c9b02 to your computer and use it in GitHub Desktop.
Player SDK

Get all players

var allPlayers = TOUT.players.getAll();

Get all players with a specific type

var topArticlePlayers = TOUT.players.byProductName(TOUT.PRODUCTS.TOP_ARTICLE);
var midArticlePlayers = TOUT.players.byProductName(TOUT.PRODUCTS.MID_ARTICLE);

Player Functions/Properties

  • play()
  • pause()
  • mute()
  • unmute()
  • tout
  • instanceID
  • productName

Example: Pause the top article player

var topArticlePlayers = TOUT.players.byProductName(TOUT.PRODUCTS.TOP_ARTICLE);
if(topArticlePlayers.length > 0){
  topArticlePlayers[0].pause();
}

Example: Get metadata for a tout

var topArticlePlayers = TOUT.players.byProductName(TOUT.PRODUCTS.TOP_ARTICLE);
if(topArticlePlayers.length > 0){
  var tout = topArticlePlayers[0].tout;
  alert("User: " + tout.user.username + "; Created at: " + tout.created_at + ", Text: " + tout.text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment