![]() |
Introduction
The interface between player and its page is based on JavaScript calls. When an event occurs in the player it calls for JS function with appropriate name, e.g. 'readyToNextClip' when the clip is finished. You can see the list of event in the example below. In order to work with AnyClip Player you need to configure it with Flash vars, to implement event handler function and call for player function from it.. Flash vars, JS functions and player functions are listed in the sections below.Flash Variables:
Set the below flashvars for the player(s) with any value:
Set the below flashvars for the player(s) with any value:
- playerId - Player type mainly used to identify the player.
- placementId - Used when more than one player with same type are placed on same page/
- JSMethodsPrefix - Prefix that should be added event calls, e.g. vs_readyToNextClip and not readyToNextClip. Mainly used when there is more than one player at the page.
- pub_keyword - Player id at ad server. Default value is 'anyclip_com'.
- clipid - AnyClip clipID for first clip to play.
- ref - Page reference sent to an Ad Server.
This practice is mainly used to identify which player has just called 'anyclipPlayerReady()'. Those flashvars are passed back as arguments to the call.
It is not strictly needed if using only one player per page. However, since the Flash ExternalInterface calls and JS calls arguments count must match to prevent a security error - set these flashvars to a random value.
Player to JS:
Important: If a value is sent in JSMethodsPrefix parameter, all functions names will contain this prefix.
anyclipPlayerReady
anyclipPlayerReady(playerId, placementId)
Called from our player when the it's loaded and all other methods and callbacks are added. Make sure you have a definition for it and wait until it's called before calling any other method on the player.
Called from our player when the it's loaded and all other methods and callbacks are added. Make sure you have a definition for it and wait until it's called before calling any other method on the player.
readyToNextClip
readyToNextClip(player,placement)
Very useful for playlists. Called by the player when it finished to play the clip and a postroll advertisment
....
You can see full list of player events in the example below.
JS to player
Important: If a value is sent in JSMethodsPrefix parameter, all functions names will contain this prefix.
load a clip by the given Id (clipId:String)
unloadClip
unloadClip()play the current paused clip (resume)
pauseClip
pauseClip()
pause the current playing clip
seekTo
seekTo(ms)
seek the current loaded clip to a specific time in milliseconds (ms:int)
mute
mute()
mute the current loaded clip
unmute
unmute()
unmute the current loaded clip
setVolume
setVolume(volume)
set the volume value between 0-1
getVolume()
return the volume value between 0-1
getClipPlayheadPosition
getClipPlayheadPosition()
return the current clip position in milliseconds
getEmbedCode
getEmbedCode()
return a string which contains the html embed code tag
getClipID
getClipID()
return the current loaded clip id (String)
Example:
<div id="playerWrap" style="background-color:#000;width:638px;height:359px">
<div id="player"></div>
</div>
<!--playerWrap-->
<script type="text/javascript" language="javascript">
var eventCounterVs = 0;
var clips = ["bscBJY2tbhbJmm","YYD42b7J2hbJmm","bscB2m4b7hbmu4","J34N72tmJhbJmm"]
var anyclip = {};
anyclip.player = {};
anyclip.player = {
position: 0,
events:
[ 'pluginLoadStart', 'pluginLoadComplete', 'pluginLoadError', 'playerLoaded', 'clipDataLoading', 'clipDataLoaded', 'adaptvLoading', 'adaptvLoaded', 'streamLoading', 'clipReady', 'adPrerollStarted', 'adMidrollStarted', 'adPostrollStarted','adPrerollEnded', 'adMidrollEnded', 'adPostrollEnded', 'adPrerollFailed', 'adMidrollFailed', 'adPostrollFailed', 'adErrorOrTimeout', 'clipStarted', 'clipEnded', 'readyToNextClip'
],
swfVersionStr: "10.0.0",
url: <link to player>,
flashvars: {
JSMethodsPrefix: 'vs_',
pub_keyword: 'anyclip_com',
playerid: 'acp_player',
placementid: 'player',
clipid: clips[0],
ref: window.location.href
},
flashparams: {
wmode: "transparent",
quality: "high",
allowScriptAccess: "always",
allowFullScreen: true
}
}
function vs_readyToNextClip(player,placement){
anyclip.player.position++;
if (anyclip.player.position == clips.length){
anyclip.player.position = 0;
}
document.getElementById('player').vs_loadClip(clips[anyclip.player.position]);
}
swfobject.embedSWF(anyclip.player.url, 'player', 638, 359, anyclip.player.swfVersionStr, null, anyclip.player.flashvars, anyclip.player.flashparams,null);
</script>