Media Module Methods

The media module methods are used to manually tracking player events and to track additional metrics that are not part of the standard video reports.

If you are using Media.autoTrack and are not tracking additional metrics, you do not need to call any of these methods directly. All arguments are required unless specified as optional.

Method Description
Media.open Syntax:
s.Media.open(mediaName,mediaLength,mediaPlayerName)

Prepares the media module to collect video tracking data. This method takes the following parameters:

mediaName: (required) The name of the video as you want it to appear in video reports.

mediaLength: (required) The length of the video in seconds.

mediaPlayerName: (required) The name of the media player used to view the video, as you want it to appear in video reports.

Media.openAd Syntax:
s.Media.openAd(name,length,playerName,parentName,parentPod,parentPodPosition,CPM)

Prepares the media module to collect ad tracking data. This method takes the following parameters:

name: (required) The name or ID of the ad.

length: (required) The length of the ad.

playerName: (required) The name of the media player used to view the ad.

parentName: The name or ID of the primary content where the ad is embedded.

parentPod: The position in the primary content the ad was played.

parentPodPosition: The position within the pod where the ad is played.

CPM: The CPM or encrypted CPM (prefixed with a "~") that applies to this playback.

Media.click Syntax:
s.Media.click(name,offset)

Track when an ad is clicked in a video. This method takes the following parameters:

name: The name of the ad. This must match the name used in Media.openAd.

offset: The offset into the ad when the click occurred.

Media.close Syntax:
s.Media.close(mediaName)

Ends video data collection and sends information to Adobe data collection servers. Call this method at the end of the video. This method takes the following parameters:

mediaName: The name of the video. This must match the name used in Media.open.

Media.complete Syntax:
s.Media.complete(name,offset)

This method manually tracks a complete event. This method is used when you need to trigger events using special logic that can't be handled using Media.completeByCloseOffset.

For example, if you are measuring a live stream that has no defined end, you might trigger a complete after a user views a live stream for X seconds. You might measure a complete using a percentage calculation based on the length and type of content. This method takes the following parameters:

mediaName: The name of the video. This must match the name used in Media.open.

mediaOffset: The number of seconds into the video when the complete event should be sent. Specify the offset based on the video starting at second zero. If your media player tracks using milliseconds, make sure the value is converted to seconds before you call Media.complete.

If you plan to call complete manually, set s.Media.completeByCloseOffset = false to disable automatic triggering of the complete event.

Media.play Syntax:
s.Media.play(name,offset,segmentNum,segment, segmentLength)

Call this method anytime a video starts playing. When using manual video measurement, you can provide the current segment data when sending video measurement data.

If your player changes from one segment to another, for whatever reason, you should call Media.stop before calling Media.play again for the new segment.

This method takes the following parameters:

mediaName: The name of the video. This must match the name used in Media.open.

mediaOffset: The number of seconds into the video that play begins. Specify the offset based on the video starting at second zero. If your media player tracks using milliseconds, make sure the value is converted to seconds before you call Media.play.

segmentNum: (Optional) The current segment number, which marketing reports use to order the display of segments in reports. The segmentNum parameter must be greater than zero.

segment: (Optional) The current segment name.

segmentLength: (Optional) The current segment length, in seconds.

For example:

s.Media.play("My Video",1800,2,"Second Quarter",1800)
s.Media.play("My Video",0,1,"Preroll",30)
Media.stop Syntax:
s.Media.stop(mediaName,mediaOffset)

Tracks a stop event (stop, pause, etc.) for the specified video. This method takes the following parameters:

mediaName: The name of the video. This must match the name used in Media.open.

mediaOffset: The number of seconds into the video that the stop or pause event occurs. Specify the offset based on the video starting at second zero.

Media.monitor Syntax:
s.Media.monitor(s, media)

Silverlight Syntax:

s.Media.monitor = new AppMeasurement_Media_Monitor(myMediaMonitor);

The Silverlight app media monitor implements the Objective-C delegate design pattern. myMediaMonitor is a class method that takes the s and media parameters.

Use this method to send additional video metrics. You can setup additional variables (Props, eVars, Events) and send them using Media.track based on the current state of the video as it is playing.

See Measuring Additional Metrics using Media.monitor.

This method takes the following parameters:

s: The AppMeasurement instance (or JavaScript s object).

media: An object with members providing the state of the video. These members include:

  • media.name: The name of the video. This must match the name used in Media.open.
  • media.length: The length of the video in seconds given in the call to Media.open.
  • media.playerName: The name of the media player given in the call to Media.open.
  • media.mediaEvent: A string containing the event name that caused the monitor call. These events are:
    • OPEN: When playback is first observed through Media.autoTrack or a call to Media.play.
    • CLOSE: When playback ends at the completion of the video through Media.autoTrack or at a call to Media.close.
    • PLAY: When playback resumes after being paused or scrubbing through Media.autoTrack or a second call to Media.play.
    • STOP: When playback stops due to a pause of the beginning of scrubbing through Media.autoTrack or a call to Media.stop.
    • MONITOR: When our automatic monitoring checks the state of the video while it's playing (every second).
    • SECONDS: At the second interval defined by the Media.trackSeconds variable.
    • MILESTONE: At the milestones defined by the Media.trackMilestones variable.
  • media.openTime: An NSDate object containing data about when Media.open was called.
  • media.offset: The current offset, in seconds, (actual point in the video) into the video. The offset starts at zero (the first second of the video is second 0).
  • media.percent: The current percentage of the video that has played, based on the video length and the current offset.
  • media.timePlayed: The total number of seconds played so far.
  • media.eventFirstTime: Indicates if this was the first time this media event was called for this video.
Media.track Syntax:
s.Media.track(mediaName)

Immediately sends the current video state, along with any Media.trackVars and Media.trackEvents you've defined. This method is used within Media.monitor.

See Measuring Additional Metrics using Media.monitor.

Call Media.open and Media.play on the video before calling this method. This method takes the following parameter:

mediaName: The name of the video. This must match the name used in Media.open.

This method is the only way to send additional variables while the video is playing.

This method resets the seconds interval and percent milestone counters to zero to prevent multiple tracking hits.