Server-Side Ad Insertion (SSAI) plugin

The SSAI plugin allows you to serve ads that are dynamically inserted into video content at the server level before content is delivered to the viewer's device. This is in contrast to client-side ad insertion (CSAI), where the viewer's device inserts ads during playback. Ad insertion on the server side is typically in real-time or near real-time. SSAI offers several advantages over CSAI, such as:

  • Server-level ad insertion makes advertisements less susceptible to ad blockers used by viewers, resulting in higher delivery rates.
  • SSAI allows for more precise ad targeting based on real-time viewer data, leading to higher ad relevance and engagement.
  • Ads are seamlessly integrated into the video stream. Therefore, viewers experience smooth playback without buffering or quality degradation during ad transitions.

The SSAI plugin can be configured to work with Google's Interactive Media Ads Dynamic Ad Insertion (IMA DAI) SDK and with Yospace.

Before you start

For Google's IMA DAI integration to work with the SSAI plugin, you need the following:

  • Access to a Google Ad Manager 360 Advanced account and a contract with Google to enable DAI.
  • To use IMA DAI pod serving, you must be working with a pod-serving partner.

Install the plugin

To install the SSAI plugin, include the plugin script next to the core player:

Copy
Copied
<script src="//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/ssai.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/id3.min.js"></script>

You must load the ID3 Metadata plugin to handle timed metadata and listen to timed metadata events. For more, see Handle timed metadata in linear DAI streams.

Configure the plugin with DAI

You can configure the SSAI plugin for use with the Google IMA DAI SDK, allowing for the seamless integration of server-side ad stitching techniques. The IMA DAI SDK returns a combined video stream, so you don't have to manage switching between ad and video content within your application. We support both of Google's Full service and Pod serving DAI solutions.

info

DAI Pod Serving is a beta intended for Ad Manager publishers and video technology partners who either have an in-house manifest manipulation service or are currently using third-party manifest manipulation that's already integrated with DAI.

The tables in this section outline the SSAI plugin configuration properties available when configuring the player with Google's IMA DAI SDK. The SSAI plugin is configured under the src namespace.

In addition to the mentioned properties, the SSAI plugin supports all stream request properties available with Google IMA DAI SDK. For a full list, see these references:

You can use these Google IMA sample streams when testing streams with your workflows.

DAI VOD stream parameters

These properties can be used when configuring the player with a DAI VOD stream request.

Property Required Applies to DAI solution Description
backupStream
string
Optional VOD Full service/Pod serving Optional back-up stream to use in case the main stream fails to play.
contentSourceId
string
Required VOD Full service Unique identifier for the publisher content from a CMS. To retrieve this ID in the Media RSS (MRSS) feed from Google, create the content source in your Google Ad Manager UI. Helps Google's ad serving systems associate the correct ad inventory and ad targeting criteria with the specific content being streamed. For more, see Google's API reference.
format
string
Required (for DASH streams) VOD Full service/Pod serving The stream format to request. Accepts hls (default) and dash string values. For more, see Google's API reference.
networkCode
string
Required VOD Pod serving Network code for the publisher making the stream request. Corresponds to the network code for your Ad Manager 360 account. Helps Google's ad serving systems route ad request and responses to the correct publisher account and manage ad inventory effectively. For more, see Google's API reference.
requestStreamUrl(streamManager, streamId)
function
Required VOD Pod serving Callback function that takes streamManager and streamId arguments. Add your code to this function to request and dynamically generate the stream URL from your video technology partner (VTP). Your function should return a Promise object with the stream URL if it's resolved or an error if the promise is rejected. For more, see Google's VOD pod-serving example code.
type
string
Required VOD Full service/Pod serving Must be set to the google/dai type to indicate that a Google DAI stream is to be used with the SSAI plugin.
videoId
string
Required VOD Full service Identifier for each individual video asset the Google MRSS feed uses to populate the content source library. Helps Google's ad serving systems to associate ad targeting criteria and ad insertion policies with specific videos. For more, see Google's API reference.

Example

The following example demonstrate how to incorporate a request for VOD assets using the DAI full-service solution. Aside from the type property, values in these examples are placeholders and must be replaced with your own.

VOD full serviceVOD pod serving (Beta)
Copy
Copied
var player = flowplayer('#container', {
  src: [{
    contentSourceId: "2548831",
    videoId: "tears-of-steel",
    type: "google/dai",
    backupStream: "http://storage.googleapis.com/testtopbox-public/video_content/bbb/master.m3u8"
  }]
});
Copy
Copied
// SSAI plugin uses networkCode to generate VOD pod serving request
// When DAI stream is initialized, SSAI plugin gets stream ID from IMA DAI SDK
// Stream ID is then passed as argument to requestStreamUrl function

var player = flowplayer('#container', {
  src: [{
    requestStreamUrl: (streamManager, streamId) => {
      // Add your code to get stream URL from your VTP
    },
    networkCode: "51636543",
    type: "google/dai",
    backupStream: "http://storage.googleapis.com/testtopbox-public/video_content/bbb/master.m3u8"
  }]
});

DAI live stream parameters

These properties can be used when configuring the player with a DAI live stream request.

Property Required Applies to DAI solution Description
assetKey
string
Required Live Full service Used to determine which live stream should play. The live stream request asset key identifier can be found in the DFP UI. For more, see Google's API reference.
backupStream
string
Optional Live Full service/Pod serving Optional back-up stream to use in case the main stream fails to play.
customAssetKey
string
Required Live Pod serving The custom asset key that identifies your pod serving event in Ad Manager 360. This can be created by your manifest manipulator or third-party pod serving partner. For more, see Google's API reference.
format
string
Required (for DASH streams) Live Full service/Pod serving The stream format to request. Accepts hls (default) and dash string values. For more, see Google's API reference.
networkCode
string
Required Live Pod serving Network code for the publisher making the stream request. Corresponds to the network code for your Ad Manager 360 account. Helps Google's ad serving systems route ad request and responses to the correct publisher account and manage ad inventory effectively. For more, see Google's API reference.
streamUrl
string
Required Live Pod serving The video stream URL provided by your manifest manipulator or third-party partner using pod serving. This URL includes a [[STREAMID]] placeholder that's replaced by the stream ID value provided by the IMA DAI SDK before the request is made. For more, see Google's live pod-serving example code.
type
string
Required Live Full service/Pod serving Must be set to the google/dai type to indicate that a Google DAI stream is to be used with the SSAI plugin.

Example

The following examples demonstrate how to incorporate a request for live stream assets using the DAI full-service and pod-serving solutions. Switch between the Live full service and Live pod serving tabs to see code snippets for using the player in each scenario. Aside fom the type property, values in these examples are placeholders and must be replaced with your own.

Live full serviceLive pod serving
Copy
Copied
var player = flowplayer('#container', {
  src: [{
    assetKey: "c-rArva4ShKVIAkNfy6HUQ",
    type: "google/dai",
    backupStream: "http://storage.googleapis.com/testtopbox-public/video_content/bbb/master.m3u8"
  }]
});
Copy
Copied
var player = flowplayer('#container', {
  src: [{
    customAssetKey: "google-sample",
    streamUrl: "https://encodersim.sandbox.google.com/masterPlaylist/9c654d63-5373-4673-8c8d-6d92b66b9d46...&stream_id=[[STREAMID]]",
    networkCode: "51636543",
    type: "google/dai",
    backupStream: "http://storage.googleapis.com/testtopbox-public/video_content/bbb/master.m3u8"
  }]
});

Configure the plugin with Yospace

You can configure the SSAI plugin to use with Yospace's DAI for live and VOD content. The following table outlines SSAI plugin configuration properties available for use with Yospace. The SSAI plugin is configured under the src namespace.

Property Description
type Set to yospace to indicate that a Yospace stream is to be used with the SSAI plugin.
src Identifies the Yospace stream.

Example

In the following example, replace the src value with your own Yospace stream.

Copy
Copied
var player = flowplayer('#container', {
  src: [{
    type: "yospace",
    src: "https://csm-e-sdk-validation.bln1.yospace.com/csm/access/12345/c2FtcGxlL21hc3Rl?yo.av=3"
  }]
});

Listen to plugin events

To listen to events for this plugin, use the ssai namespace in the player instance. For example, use flowplayer.ssai.events to capture an event. The following table describes the object path and events for the SSAI plugin.

Event Description
flowplayer.ssai.events.SSAI_AD_COMPLETED Fires when an individual ad completes.
flowplayer.ssai.events.SSAI_AD_END Fires the first time each ad break ends.
flowplayer.ssai.events.SSAI_AD_START Fires the first time each ad break begins playback.
flowplayer.ssai.events.SSAI_AD_STARTED Fires when an ad starts.
flowplayer.ssai.events.SSAI_AD_PAUSED Fires when an ad pauses.
flowplayer.ssai.events.SSAI_AD_PROGRESS Fires when the current ad progresses.
flowplayer.ssai.events.SSAI_AD_RESUMED fires when an ad resumes.
flowplayer.ssai.events.SSAI_AD_SKIPPED Fires when the user skips an ad.

For example, use the following code to set up an event listener capturing when a server-side ad is paused. Then add your custom logic inside the callback function:

Copy
Copied
player.on(flowplayer.ssai.events.SSAI_AD_PAUSED, (event)=>{
  // Add your code here
  console.log('Server-side ad paused.');
});