Web Player

Player configuration reference

Players configuration methods

This page shows common configurations, each with a ready-to-use embed code. The player supports more options than are listed here.

Configure a player to run a single video

The following example runs a single video hosted on TargetVideo.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID"});
</script>

Configure a player to run with a playlist

The following example runs a playlist hosted on TargetVideo.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","playlist":"PLAYLIST_ID"});
</script>

Configure a player to run with latest videos playlist

The following example runs a playlist of the latest videos from your TargetVideo account. The tag playlist below uses the same playlist object, which also accepts "items", the number of videos to load per page (default 25).

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","playlist":{"id":"0","mode":"latest"}});
</script>

Configure a player to run latest videos by tag playlist

The following example runs a playlist of the latest videos with a specific tag.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","playlist":{"id":"VIDEO_TAG","mode":"tag"}});
</script>

Configure a player to run custom external video URL

The following example plays a video from your own external URL.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270",
        "video":{
            "Video": [
                {
                    "source": {
                        "ld": "240p_mp4_video_url",
                        "sd": "360p_mp4_video_url",
                        "hsd": "480p_mp4_video_url",
                        "hd": "720p_mp4_video_url"
                    }
                }
            ]
        }
    });
</script>

Set custom sticky position

If you want to configure the player to go into a custom sticky position/location you can do it by adding the following "slide_inposition": "#STICKY_DIV_ID" parameter in the embed code. This field can accept any kind of CSS selector.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID","slide_inposition":"#STICKY_DIV_ID"});
</script>

Configure playback behavior based on traffic source

To make the player autoplay or click to play depending on where the visitor came from, add "alterPlaybackBehaviour" to the embed code. The player checks the page the visitor came from (document.referrer) and changes its autoplay setting when that page is on one of the listed sites. Set an option to true to use its defaults:

  • "onOrganicTraffic" — click to play for visitors coming from Google, Bing or Yahoo.

  • "onSocialTraffic" — autoplay for visitors coming from Facebook, Instagram or Pinterest.

If the visitor came from any other site, or the browser sends no referrer, the player keeps its own autoplay setting.

Example

$bp("DIV_ID", {"id":"PLAYER_ID","width":"640","height":"360","video":"VIDEO_ID",
    "alterPlaybackBehaviour":{
        "onOrganicTraffic":true,
        "onSocialTraffic":true
    }
});

To choose the behaviour and the sites yourself, pass an object instead of true: "behaviour" is "clickToPlay" or "autoPlay", and "forSites" lists site names to match against the referrer’s domain (for example, "google" matches google.com and www.google.de).

Example

$bp("DIV_ID", {"id":"PLAYER_ID","width":"640","height":"360","video":"VIDEO_ID",
    "alterPlaybackBehaviour":{
        "onOrganicTraffic":{
            "behaviour":"clickToPlay",
            "forSites":["google"]
        },
        "onSocialTraffic":{
            "behaviour":"autoPlay",
            "forSites":["facebook", "linkedin"]
        }
    }
});

Turn off default player localization

By default, player will setup localization by reading the HTML lang attribute from the page. If you want to turn this off you can do that by adding the following parameter in player's embed code: "turnOffLocalization": true

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:640px;height:360px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"640","height":"360","video":"VIDEO_ID","turnOffLocalization":true});
</script>

Set up custom logo size in the player

Using the below piece of code you can customize the logo in the player easily.
This piece of code needs to be setup on the page where the player is embedded.

Example

<style>
    .bplr-branding {
        width: 200px;
        height: 200px;
        max-width: 50%;
        max-height: 50%;
    }
</style>

Set up custom snapshot image for the player

To show your own image instead of the video’s snapshot, add poster with the image URL to the embed code:

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID","poster":"IMAGE_URL"});
</script>

Use the page’s og:image as the snapshot

To show the image from the page’s og:image tag (<meta property="og:image" content="IMAGE_URL">) instead of the video’s snapshot, set use_og_image_as_snapshot to true in the embed code. This is the same as the player setting Options > Use og:image/featured image as snapshot in the CMS; the embed code overrides that setting for its own embed, so false turns it off there.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID","use_og_image_as_snapshot":true});
</script>

📘 Note

The og:image takes priority over both poster and the video’s snapshots. If the page has no og:image tag, or it is empty, the player uses poster, then the video’s snapshot.

Set the snapshot quality

By default, the player picks the snapshot whose size best fits the player’s height. To always use a specific size, add force_snapshot_quality to the embed code, for example for a sharper image on high-resolution screens or a smaller one to save bandwidth:

Value

Snapshot used

ld

240p

sd

360p

hsd

480p

mhd

540p

hd

720p

fhd

1080p

qhd

1440p

uhd

2160p

fuhd

4320p

auto

The largest snapshot the video has

If the video has no snapshot in the chosen size, the player uses the next larger one, or the largest one if there is no larger.

Example

<script type="text/javascript" src="https://player.target-video.com/player/build/targetvideo.min.js"></script>

<div id="DIV_ID" style="width:480px;height:270px;"></div>

<script type="text/javascript">
    $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID","force_snapshot_quality":"fhd"});
</script>

📘 Note

The option only applies to the snapshot shown before the first video starts. It has no effect when the embed code sets its own image with poster or the page’s og:image is used (use_og_image_as_snapshot), see above. An unknown value is ignored.

Consent and privacy options

Add these to the embed code to control how the player handles consent and ad privacy:

  • wait_tcf_api (boolean) — wait for the page’s IAB TCF consent tool (__tcfapi) before requesting ads, and fill the [gdpr] and [consent] macros in your ad tags. Prebid and Amazon bidding wait for it too, and are skipped if the page has no TCF tool. If no consent answer arrives in time, the video plays without ads. Without this option, the player checks consent only when an ad tag contains [gdpr], [consent] or [npa], and still requests ads when the page has no TCF tool.

  • wait_gpp_api (boolean) — the same for the IAB Global Privacy Platform (__gpp): wait for it before requesting ads and fill the [gpp] macro. Without this option, GPP is checked only when an ad tag contains [gpp].

  • ima_secure_mode (boolean) — run VPAID ads in Google IMA’s secure mode. By default the player uses IMA’s insecure VPAID mode.

  • nonce_ppid (string) — a publisher-provided ID (PPID) passed to Google’s Programmatic Access Library (PAL) when an ad tag contains the [paln] or [nonce] macro.

Example

$bp("DIV_ID", {"id":"PLAYER_ID","width":"640","height":"360","video":"VIDEO_ID",
    "wait_tcf_api":true,
    "wait_gpp_api":true,
    "ima_secure_mode":true
});
Player configuration reference · TargetVideo Developer Docs