Playback URLs

Learn how to:

Assets

Use either of the following types of playback URLs to stream an asset:

Key information:

Asset ID

Upon the creation of an asset, it is assigned a 32-character hexadecimal unique identifier. This ID, known as an asset ID, may be viewed via the CMS, a slicer's output, logs, the Preplay API, or the SegmentMap interface. Construct a playback URL by including this asset ID.

HLS Syntax:

https://content.uplynk.com/Asset ID.m3u8

DASH Syntax:

https://content.uplynk.com/Asset ID.mpd

Sample playback URL (HLS):

Use the following playback URL to stream an asset with an ID of 7771125f336c4e229c20f7307f8c3122 via HLS.

https://content.uplynk.com/7771125f336c4e229c20f7307f8c3122.m3u8

External ID (Asset)

A playback URL may be constructed by including both of the following values:

HLS Syntax:

https://content.uplynk.com/ext/User ID/External ID.m3u8

DASH Syntax:

https://content.uplynk.com/ext/User ID/External ID.mpd

Sample Playback URL (HLS):

Use the following playback URL to stream an asset with an external ID of promo_video_12 that is owned by a user whose ID is f8c29a5f6c4e229c20f7307f8c3122ab.

https://content.uplynk.com/ext/f8c29a5f6c4e229c20f7307f8c3122ab/promo_video_12.m3u8

Segment (Ad Breaks)

Use this type of playback URL to stream a segment of an asset that contains ad breaks.

Server-side ad insertion ensures seamless ad integration. As a result, this type of playback URL is typically reserved for legacy client-side ad integrations or non-video ad integrations in which video playback is temporarily suspended.

Starting/Stopping Playback by Time or Slice

Restrict playback by specifying a starting or stopping point via the following customization parameters:

Playing Multiple Videos

Multiple videos may be defined within a playback URL. This combines multiple videos into a single playlist (i.e., m3u8) which allows a media player to play them back as if they were a single asset.

An alternative method of playing multiple videos is to create a virtual linear playlist. The benefits of using a virtual linear playlist instead of manually defining multiple assets within a playback URL are faster player load times and higher monetization by eliminating or reducing ad request timeouts, stale ads, and the unnecessary depletion of ad inventory.

Key information:

Virtual Linear Playlists

Manage virtual linear playlists through the Virtual Linear Playlist API. Upon creating a virtual linear playlist, it is assigned a 32-character hexadecimal unique identifier. Use this ID, which is known as a playlist ID, when constructing a playback URL.

Smartstart provides a virtual linear experience for a single asset. Use the Bulk Smartstart endpoint to enable Smartstart on one or more asset(s) by creating a virtual linear playlist for each asset. This type of virtual linear playlist is assigned the same system-defined ID as its asset. This facilitates playback implementation, since it allows you to use this shared ID when constructing a playback URL.

HLS Syntax:

https://content.uplynk.com/playlist/Playlist ID.m3u8

DASH Syntax:

https://content.uplynk.com/playlist/Playlist ID.mpd

Sample playback URL (HLS):

Use the following playback URL to stream a playlist with an ID of 7771125f336c4e229c20f7307f8c3122 via HLS.

https://content.uplynk.com/playlist/7771125f336c4e229c20f7307f8c3122.m3u8

Key information:

  • Use the virtual linear playlist's skip_drm property to determine whether a digital signature is required. This property overrides an asset's Require a token for playback setting.
  • Use the virtual linear playlist's studio_drm_required property to determine whether it will be protected by Studio DRM. This property overrides an asset's Require studio approved DRM for playback setting.
  • If you plan on implementing a timeline within your player, use the dmm.schemas.top and pltl query string parameters to include timeline data within the manifest.

    The pltl query string parameter is optional for Smartstart-enabled assets.

  • Learn more about virtual linear playlists and Smartstart.

Live Channels

The two types of playback URLs for a live channel are:

Channel ID (GUID)

Upon the creation of a live channel, it is assigned a 32-character hexadecimal unique identifier. View this ID, known as a channel ID, from within the CMS.

Generate a playback URL for a live channel by including its channel ID.

HLS Syntax:

https://content.uplynk.com/channel/Channel ID.m3u8

DASH Syntax:

https://content.uplynk.com/channel/Channel ID.mpd

Sample playback URL:

The following sample playback URL plays a live channel with an ID of cd772adbd60a4e898d1c3b1f46c58cea.

https://content.uplynk.com/channel/cd772adbd60a4e898d1c3b1f46c58cea.m3u8

External ID (Channel)

A playback URL may be constructed by including both of the following values:

HLS Syntax:

https://content.uplynk.com/channel/ext/User ID/External ID.m3u8

DASH Syntax:

https://content.uplynk.com/channel/ext/User ID/External ID.mpd

Sample playback URL:

The following sample playback URL plays a live channel with an ID of live_feed_east provided that it belongs to a user whose user ID is f8c29a5f6c4e229c20f7307f8c3122ab.

https://content.uplynk.com/ext/f8c29a5f6c4e229c20f7307f8c3122ab/live_feed_east.m3u8

Live Events

The two types of playback URLs for a live event are:

Event ID (GUID)

An event ID is automatically generated upon creating a live event.

An alternative method for scheduling a live event is via the Live Events Integration API. An event ID is reported by the id response parameter when creating, updating, or retrieving a live event.

Generate a playback URL for a live event by including its event ID.

HLS Syntax:

https://content.uplynk.com/event/Event ID.m3u8

DASH Syntax:

https://content.uplynk.com/event/Event ID.mpd

Sample playback URL:

The following sample playback URL plays a live event with an ID of f21c3336c35f47baa59345e2879b6edb.

https://content.uplynk.com/event/f21c3336c35f47baa59345e2879b6edb.m3u8

External ID (Event)

A playback URL may be constructed by including both of the following values:

HLS Syntax:

https://content.uplynk.com/event/ext/User ID/External ID.m3u8

DASH Syntax:

https://content.uplynk.com/event/ext/User ID/External ID.mpd

Sample playback URL:

The following sample HLS playback URL plays a live event with an ID of live_feed_east provided that it belongs to a user whose user ID is 1855369d5db040539700c6cb724d1f16.

https://content.uplynk.com/event/ext/1855369d5db040539700c6cb724d1f16/live_feed_east.m3u8

Signing Playback URLs with a Token

Control how and when content is consumed by informing our system when playback should be allowed by including an HMAC token that signs your playback URL. By default, an asset, live channel, or live event is configured to require a digital signature prior to playback. This digital signature must be appended to the playback URL's query string. Upon requesting playback, our system will use the digital signature to validate that the playback windowPlayback is disallowed once the digital signature expires. has not expired and the integrity of the playback URL and query string. Playback will only be allowed once the digital signature has been validated.

To determine whether playback URLs must be signed

  1. From the CMS, perform one of the following:

    • Asset: Select the desired asset from the Content tab and then click the Playback tab.
    • Live Channel: Select the desired live channel from the Live Channels tab and then click the Playback tab.
    • Live Event: Open the desired live event from the Live Events page and then click the Config tab.
  2. Toggle the state of the Require a token for playback option to determine whether the playback URL must be signed.
  3. Click Save.

Exceptions

Our system automatically hosts a playback page and signs playback URLs under the following circumstances:

Key information:

Basic Setup

Most programming languages only require a few lines of code to sign a playback URL.

Define what will be signed and the digital signature through the following query string parameters:

Syntax:

Playback URL?Core Identification Parameters&Optional Customization Parameters&sig=Signature

Example:

Core Identification Parameters

The following core identification parameters must be specified:

Parameter Description

tc

Identifies the token check algorithm version. Set this parameter to 1.

Example:

tc=1

exp

Determines when, in Unix time, this signed playback URL expires.

Digital signatures should have a short lifespan. However, they should not expire less than 10 seconds after being issued, since this may block playback for legitimate users whose system time is not properly synched with a public time server.

Example:

exp=1530316768

rn

Defines a random number that increases the uniqueness of the signature.

Example:

rn=4114845747

ct

Identifies the type of content that will be played back.

Valid values are:

  • a: Asset
  • c: Live channel
  • e: Live event
  • p: Virtual linear playlist (including Smartstart-enabled assets)

Example:

ct=a

cid

Or:

eid & oid

Identifies an asset, channel, live event, or virtual linear playlist via one of the following methods:

Digital Signature

A digital signature protects the playback URL against tampering by allowing our system to validate the playback URL's query string against a hashed version of it.

Key information:

Sample Code

Sample code that signs a playback URL is provided below.

Python 3 sample code:

import hashlib, time, hmac, urllib.parse, random

# Update to your API key. 
apiKey = 'WxQpQhHFmE4hTWA4TGLu6rYeNuKgYrWwlCLmSKRb' 

# Set to all of the playback URL's query string parameters except the signature.
queryStr = urllib.parse.urlencode({
    'tc': '1', # token check algorithm version
    'exp': int(time.time()) + 60, # expire 60 seconds from now
    'rn': str(random.randint(0, 2**32)), # random number
    'ct': 'a', # an asset
    'cid': 'ea10fa402fec4bbe996019a0827e6c38', # the asset's ID
    'rays': 'dcba', # customization parameter
})

# Compute the signature and add it to the *end*
sig = hmac.new(apiKey.encode('utf-8'), queryStr.encode('utf-8'), hashlib.sha256).hexdigest()

queryStr = queryStr + '&sig=' + sig

# Add the query string to the playback URL.
url = 'https://content.uplynk.com/ea10fa402fec4bbe996019a0827e6c38.m3u8'
url = url + '?' + queryStr

PHP sample code:

<?php
// inputs
$apiKey = "WxQpQhHFmE4hTWA4TGLu6rYeNuKgYrWwlCLmSKRb" // from the CMS UI

// combine all of the parameters
$msg = array();
$msg["tc"] = "1"; // token check algorithm version
$msg["exp"] = time() + 60; // expire 60 seconds from now
$msg["rn"] = rand(); // random number
$msg["ct"] = "a"; // an asset
$msg["cid"] = "ea10fa402fec4bbe996019a0827e6c38"; // asset ID
$msg["rays"] = "dcba"; //customization parameter

// Calculate signature
$msg["sig"] = hash_hmac("sha256", http_build_query($msg), $apiKey);

// Add the query string the playback URL.
$url = 'https://content.uplynk.com/ea10fa402fec4bbe996019a0827e6c38.m3u8'
return $url . '?' . http_build_query($msg);

Encrypting Query Strings

A playback URL may either be passed as cleartext or encrypted text. Encrypting query strings is useful for masking keywords (e.g., ad) that may trigger an ad blocker.

To encrypt a playback URL's query string

  1. Generate a query string value that signs your playback URL.
  2. Copy an API key.

  3. Generate a MD5 hash of your chosen API key.

    This hash should be exactly 16 bytes (128 bits) long.

  4. Encrypt the query string using AES-128 in CBC mode.

    • Use the MD5 hash as the key for this operation.
    • Use 16 null bytes as the initialization vector.
  5. Perform URL-safe Base64-encoding on the encrypted result.

    This typically means replacing all "+" characters with "-" and all "/" characters with "_." Some languages and libraries have URL-safe-specific functions for achieving this.

  6. Set the playback URL's query string to:

    Playback URL's query string syntax:

    API keys and their IDs are listed next to each other within the CMS.

    If a playback URL contains both of the above parameters, then our system will decrypt the value assigned to cqs using the API key identified by the kid parameter. After which, it will establish a normal playback session using the information from the decrypted string.

Sample Code

Sample code that encrypts query strings is provided below.

Python 3 sample code:

import base64
import hashlib

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.padding import PKCS7
from cryptography.hazmat.backends import default_backend

API_KEY = b'cL8Z0+DHCJZqpsN6/tlB01oyxFfeElj3t7PnwWRI'
KEY_ID = 'ad5ba943177f4a1587795a9ee8d47293'

MD5_KEY = hashlib.md5(API_KEY).digest()

# This query string is signed for an asset with an asset ID of 340ca73eb07c4f4ca08b804c47a91f1b,
# owned by a user with a user ID of ba8cb548202840d48d1255885d7bb2f3
SIGNED_QUERY_STRING = b'ad=fwvod&cid=340ca73eb07c4f4ca08b804c47a91f1b&oid=ba8cb548202840d48d1255885d7bb2f3&exp=1492596978713&test=1&rn=310292100&tc=1&ct=a&sig=2ff94739b021912712adafeccd6fa291f11eef0648c3b18b30224b84e0590b4f'

def encrypt_aes_128_cbc(key, data):
    backend = default_backend()
    aes = algorithms.AES(key)
    iv = b'\x00' * 16  # Initialization vector of 16 null bytes
    cbc = modes.CBC(iv)
    padder = PKCS7(aes.block_size).padder()
    padded_data = padder.update(data) + padder.finalize()

    encryptor = Cipher(aes, cbc, backend).encryptor()
    result = encryptor.update(padded_data) + encryptor.finalize()
    return result

# Encrypt the query string using the MD5 hash of the selected API key
crypted_qs = encrypt_aes_128_cbc(MD5_KEY, SIGNED_QUERY_STRING)

# Encode the encryption result as URL-safe base64
encoded_qs = base64.urlsafe_b64encode(crypted_qs).decode("utf-8")

new_params = {'cqs': encoded_qs, 'kid': KEY_ID}

# This will be the new playback URL to request from our system.
url_with_crypted_qs = 'https://content.uplynk.com/340ca73eb07c4f4ca08b804c47a91f1b.m3u8?cqs={cqs}&kid={kid}'.format(**new_params)

print(url_with_crypted_qs)

### Value of `url_with_crypted_qs` is:
### https://content.uplynk.com/340ca73eb07c4f4ca08b804c47a91f1b.m3u8?cqs=gYXTAVtWRvk0qCs8pM9CmgprLvyQt9jNDETBL4ApLCqf2iFh-c9tXSk2Q_EbAAFc4q19KTikvqx8-StlruVaLafXU2NciESn-ZNPa-thp8UXSWwKszIp8oBjx8SJr9fcwUmu9El-w2q9lQ61nu1pk1JxomEraZAtfie9k8f5vAklpyYg5Ejd6i7iokxFO1XflOJFkhnDHp1ozCXVgh-rYKuCbbOEUwAaGYgd4zjn88GBgO1ZY8Jn3OFyGssvOydsPAnRjQmPsfFE24wYsp1Mlg==&kid=ad5ba943177f4a1587795a9ee8d47293

Scheme (HTTP vs HTTPS)

The playback URL's scheme determines the scheme used for the ray and slice responses.

Playback URL Ray and Slice Response

HTTP

HTTP

HTTPS

HTTPS

Application Keys

An application key provides an additional layer of security when transferring content keysAuthorizes playback for a limited time period. Upon receiving a key renewal request from the client, Uplynk may extend the lifespan of the content key. to an application (e.g., media player).

To set up application key support

  1. Add an application key.

  2. Update your application to pass an application key to our client SDK.

    Although application keys are displayed in the CMS as a string value, they should be treated as binary data. For example, if the CMS shows an application key of "88051e9b," the actual value for the application key is the following sequence of bytes: 0x88 0x05 0x1E 0x9B.

    Take steps to protect your application against reverse engineering.

  3. Enable application keys by including the ak configuration parameter in the playback URL's query string.

    Upon including this parameter, the signed playback URL will only work with an application key.

  4. Modify the file extension defined in a playback URL from "m3u8" to "json."

    Sample playback URL:

    https://content.uplynk.com/channel/ext/8bb3fcf33d134160848b3051fa15ea21/live_feed_east.json?tok=...

How Does It Work?

Upon receiving a playback request, our system transfers a content key to the media player over a secure HTTPS connection. Take advantage of an application key, which is a secret key embedded in a device or application, to apply an additional layer of encryption when transferring a content key.

Application keys require an application that leverages our client SDK.

Application keys require client-side functionality and therefore cannot be used for web-based playback.

More Information