API Reference

Player Methods & Events

Subscribing to Events

The StreamRail player uses Node.js Event Emitter syntax. For example, after creating a new instance of the player, here is how you subscribe to the "AdImpression" event:

copy

<script>
player.on('AdImpression', function(data) {
	console.log('AdImpression emitted by the player');
});
</script>

	    							

Function Calls

The StreamRail player function calls are in functional getter/setter style. Any function that represents an action that you can both get and set receives either a boolean value to activate the action or 'undefined' value in order to get the current state. For example, here is how you get and set the muted state:

copy

<script>
// get current muted state
var isVolumeMuted = player.muted();

// set muted = true
player.muted(true);
</script>

	    							

Player Methods

  • autoplay
  • controls(true/false) - hide or show controls
  • currentSrc
  • currentTime
  • currentType
  • duration
  • ended
  • error
  • exitFullscreen
  • isFullscreen
  • load
  • muted
  • pause
  • paused
  • play
  • preload
  • remainingTime
  • requestFullscreen (requires user gesture, available only for content)
  • seeking
  • src
  • volume

Player Events

  • contentStart

    This event is emitted when the player is starting to play content

  • contentEnd

    This event is emitted when the player is done playing content

  • playerDone

    This event is emitted when the player is done playing the ad and content.

  • waiting
  • volumechange
  • timeupdate
  • seeking
  • seeked
  • progress
  • play
  • pause
  • fullscreenchange
  • firstplay
  • error
  • ended
  • durationchange

Ad Events Emitted By The Player


All VAST/VPAID events are emitted by the player. Different versions of VAST and VPAID (e.g. VPAID2) specify different events. The player follows the official IAB spec. In the case of VPAID/VPAID2, the player may rely on the loaded ad unit to realize the events.

  • AdRequest

    This event is a custom event (rather than an IAB event). The player emits it immediately before making an http request to get the ad tag url.

  • AdResponse

    This event is a custom event (rather than an IAB event). The player emits it immediately after receiving an http response after requesting the ad tag URL.

  • AdLoaded
  • AdStarted

    This event is only emitted on VPAID/VPAID2. It is not reported on VAST since it has no meaning (no ad manager exists to start).

  • AdStopped
  • AdSkipped
  • AdSkippableStateChange
  • AdSizeChange
  • AdLinearChange
  • AdDurationChange
  • AdExpandedChange
  • AdRemainingTimeChange
  • AdVolumeChange
  • AdImpression
  • AdVideoStart
  • AdVideoFirstQuartile
  • AdVideoMidpoint
  • AdVideoThirdQuartile
  • AdVideoComplete
  • AdClickThru
  • AdInteraction
  • AdUserAcceptInvitation
  • AdUserMinimize
  • AdUserClose
  • AdPaused
  • AdPlaying
  • AdLog
  • AdError