Conviva Xbox One/Windows 10: WinJS Sensor Integration

Explains how to integrate the Conviva sensor in Xbox One and Windows 10 WinJS players to collect video streaming experience data.

Updated 2026-08-03 xbox, winjs, stream, sensor, sensor developer center, sensor integration, xbox winjs

CAUTION: Ad Monitoring support is not available currently. Please reach out to your Conviva representative if the support is required.

Follow these instructions to complete the Conviva VSI Sensor integration on Windows/Xbox One WinJS players.

Step 1: Install Conviva Library

  • Install the Conviva library and add dependencies.

  • Initialize the main Conviva object.

Developer Steps

  • Install the Conviva library and add dependencies.

  • Initialize the ConvivaUWP.WinClient object using your CUSTOMER_KEY.

  • Create an instance of ConvivaUWP.WinClient to report video related events.

Step 2: Configure Metadata

  • Most metadata is autocollected.

  • Configure additional custom metadata tags (if applicable).

Developers Steps

  • Use the pre-defined metadata key/value pairs.

  • Optionally, set custom metadata.

Step 3: Report Events and Metadata

  • Use Conviva methods to report video stream events and metadata. Conviva computes stream data and metrics.

Developer Steps

  • Implement the ConvivaUWP.WinClient.createSession(contentInfo, jsNotifier) method to report playback attempt request along with metadata (content, workflow, audience, and other relevant metadata).

  • Wrap the player with a monitoring proxy ConvivaUWPJS.VideoElementConvivaStreamerProxy( player );

  • Use the ConvivaUWP.WinClient.cleanupSession() method to report end of playback.

Step 4: Handle User Actions

Use Conviva methods to report custom events.

Developer Steps

  • Report custom events.

Step 5: Clean Up Session

  • Use Conviva release methods to clean up objects on player application exit.

Developer Steps

  • Call the ConvivaUWP.WinClient.cleanupSession() and videoElementStreamerProxy.Cleanup() API's to gracefully end the monitoring session associated with current video asset playback.

Prerequisites

  • Obtain your account's CUSTOMER_KEYs.**Conviva provides a test account and a production account for Test and Production environments, respectively. You can find your CUSTOMER_KEY here: Pulse - Account Info. Ask your Conviva representative for assistance if you have problems accessing it.

  • Pass the gatewayUrl parameter to init() method of Conviva SDK. The gatewayUrl is specific for your account and shall ONLY be used for tests, never for production deployment.

    Sample gatewayUrl for Testing:

    https://<*customer_key*>.ts-testonly.conviva.com

    IMPORTANT: If there's any doubt on how to set the gateway URL, consult your Conviva representative - this is a critical parameter. For production, Conviva library uses the automatically-assigned gatewayUrl.

    Use Touchstone 2.0 in Pulse to perform self-validation and debugging of video sensor integration

  • For Conviva JavaScript Sensor Integration, you can use any custom gateway URL with a proxy service setup. This is applicable for JavaScript version 4.7.13 onwards.

  • Plan your metadata

    Conviva supports Pre-defined, Device, and Custom metadata. Work with your project team to determine the need to collect any custom metadata. It's also recommended to work with your Conviva representative to create your metadata plan prior to integration.

  • Integration Summary

    1. Install Conviva Library
    • Install the library and add dependencies.
    • Initialize the ConvivaUWP.WinClient object using your CUSTOMER_KEY.
    • Using an instance of ConvivaUWP.WinClient report video related events.
    1. Configure Metadata
    • Implement the metadata by following the instructions to use the pre-defined keys, as well as custom metadata if defined.
    • Conviva library autocollects device metadata.
    1. Report Events and Metadata
    • Implement the ConvivaUWP.WinClient.createSession(contentInfo, jsNotifier) method to report playback attempt request along with metadata (content, workflow, audience, and other relevant metadata).
    • Wrap the player with a monitoring proxy ConvivaUWPJS.VideoElementConvivaStreamerProxy( player );
    • Use the ConvivaUWP.WinClient.cleanupSession() method to report the of end playback.
    • Implement advanced metadata and events as prescribed by the corresponding specification.
    1. Handle User Actions
    • Report ad break start / end.
    • Pause/Resume monitoring of video metrics by marking the start and end of ads in the video stream.
    • Conviva library autocollects Network Metrics.
    1. Clean Up Call the ConvivaUWP.WinClient.cleanupSession() and videoElementStreamerProxy.Cleanup() API's to gracefully end the monitoring session associated with current video asset playback.

    Test and Validate

    1. After integration, perform a sanity check following the test cases in the Stream Sensor Sanity Test Plans spreadsheet. For the full validation test, use the test cases in the Stream Sensor Full Test Plans spreadsheet.

    2. Use Touchstone in Pulse to perform self-validation and debugging of video sensor integration.

    Be sure to replace your TEST CUSTOMER_KEY with the PRODUCTION key to go live with your application, and generate the session traffic to the following Touchstone gateway URL: https://.ts-testonly.conviva.com
    1. Done! Analyse your data in Pulse and improve your viewer experience - let's make video experience better!

    1. Install Conviva Library

    Add Conviva Libraries and Configure Dependencies

    Add core SDK

    Conviva Windows 10 / Xbox One WinJS library currently supports desktop systems, mobile phones, and tablets.

    Download and add the library explicitly:

    Conviva Windows 10/Xbox One: WinJS library

    Initialize the top level object

    Conviva initialization is a one-time call that must occur at the earliest possibility in your application's initialization flow.

    ConvivaUWP.WinClient.init( customerKey, winSettings ):

    • customerKey: string to identify specific customer account. Different keys shall be used for development / debug versus production environment. Find your keys on the account info page in Pulse;

    • winSettings: ConvivaUWP.WinSettings(); settings to enable debug.

    No need to set gatewayUrl and LogLevel settings for your production release explicitly. The Conviva sensor has the right default value.

    The allowed parameters are:

    • winSettings.setGatewayUrl: once enabled, the data will appear in Pulse for performing self-validation of video sensor integration. For more information, see Self-validation using Touchstone.

    • winSettings.setLogLevel: set to ConvivaUWP.LogLevel.debug for debug-level log verbosity.

    Sample code illustrating initialization with/without debug:

    //test or dev phase
    var customerKey = TEST_CUSTOMER_KEY;
    var winSettings = new ConvivaUWP.WinSettings();
    winSettings.setGatewayURL(TOUCHSTONE_SERVICE_URL);
    winSettings.setLogLevel(ConvivaUWP.LogLevel.debug);
    ConvivaUWP.WinClient.init( customerKey, winSettings );
    
    //production release
    var customerKey = PRODUCTION_CUSTOMER_KEY;
    var winSettings = new ConvivaUWP.WinSettings();
    ConvivaUWP.WinClient.init( customerKey, winSettings );
    

    IMPORTANT: No need to set GatewayUrl and LogLevel settings for your production release. The Conviva library provides the default values for production.

    Expected Errors Due to Dual Stack IPv4/v6 Network Support

    When the Conviva sensor is initialized with production settings, the SDK sends a single request to the endpoints below:

    • [customer_key].ipv4.cws.conviva.com for IPv4 only

    • [customer_key].ipv6.cws.conviva.com for IPv6 only

    Sending both requests enables correlation of IPv4 and IPv6 addresses in dual-stack networks. If only IPv4 or IPv6 addressing is used (single-stack networking), it is expected that one request will fail. All the following requests will be sent to the endpoint below which supports both IPv4 and IPv6:

    • [customer_key].cws.conviva.com

    2. Configure Metadata

    Metadata enables analysis of your data using different dimensions, for example, content, audience, device, workflow, player, and operating system.

    Conviva categorizes metadata tags into three buckets (Predefined, Device, Custom).

    Pre-defined Video and Content Metadata

    Conviva defines the constants or fixed string keys for commonly used metadata. These metadata keys provide critical information about video content, versioning, workflow.

    Populate contentInfo object an instance of ConvivaUWP.WinContentInfo() with the specified metadata.

    IMPORTANT: To assign content category labels, such as Audio, Trailer, Tile Play, or Short Video, use the c3.cm.categoryType pre-defined content metadata constant.

    Constants for Pre-defined Video and Content Metadata

    Key Type Implementation Note
    assetName string contentInfo.setAssetName(string assetName) For video content, use unique name for each stream/video asset. Values are up to your choice, but a human-readable text prefixed with the unique video ID works best in most Conviva sensors. This provides for clarity in reports and makes most popular content easily identifiable. Pattern: [videoID] Video Title

    The following are typical patterns for VOD (movies and episodic content) and Live streams: Movie Pattern: [{contentId}] {Movie Title} Sample Value: [12345] The ABC Movie Episode Pattern: [{contentId}] {Show Title} - S:{Season Number}:E{Episode Number} - {Episode Title} Sample Value: [67890] The XYZ Show - S3:E1 - The Pilot Episode Live Stream Pattern: [{channelNumber}] {Chanel Name} Sample Value: [10] PQRS Bay Area

    isLive integer contentInfo.setIsLive(integer isLive);

    Denotes whether the content is video on-demand or a live stream. Affects the computation and availability of the Conviva metrics. 0 = VOD and 1 = Live

    playerName string contentInfo.setPlayerName(string playerName)

    A string value used to distinguish video players (applications). Simple values that are unique across all of your integrated platforms work best here. If the same player used across multiple platforms, e.g Tizen, LG TV, WEB, give separate names for each application / platofrm: e.g "JS Tizen", "JS LGTV", "JS WEB". Do not include the build or version number in this property. The intention is to have a simple way of differentiating data from different players / platforms.

    viewerId string contentInfo.setViewerId(string viewerId)

    Required for Viewers Module. A unique identifier to distinguish individual viewers or devices through Conviva's Viewers Module. The value shall be unique abstract user's identifier. If user is anonymous, do not set any value for this tag.

    streamUrl string

    contentInfo.setStreamURL(string streamURL)

    The manifest URL of the video stream.

    The Conviva backend config server attempts to map a portion of StreamURL into a CDN name. For example: In the URL https://www.akamai.net/avengers.m3u8, akamai.net maps to the AKAMAI label. Conviva VSI users can then retrieve metrics based on the mapped CDN name (AKAMAI, in this case).

    The URL values reported in the streamURL are case insensitive. The streamURLs with either uppercase or all lowercase are acceptable.
    defaultCDN string contentInfo.setDefaultCDN(string defaultCDN)

    This value specifies the video server or CDN name from where the streaming resource is played. Set this field when the video server resource cannot be inferred from the STREAM_URL.

    For example, if the streamURL is https://cbd12348.cdn.cms.somewebsitehostname.com/abc.txt, it is not possible to infer the AKAMAI name from the streamURL, and in such a case, it is necessary to report the DEFAULT_Resource as AKAMAI.

    The DEFAULT_Resource value is case sensitive. If the resource name is initially reported as AKAMAI (uppercase) and subsequently modified in the app to akamai (lowercase), it is necessary to inform Conviva about the change because both need to be mapped in the Conviva backend configuration server to ensure that both point to the same CDN name (AKAMAI).
    duration integer Autocollected by the Conviva library.contentInfo.setDuration(integer duration) Duration of the video content, in seconds.
    Player Framework Name string Autocollected by the Conviva library.
    Player Framework Version string NOTE: Refer to the existing Limitations.
    "c3.app.version" string contentInfo.setTag("c3.app.version", string value) Application build version.
    "c3.cm.contentType" string Advanced content delivery methods along with Live and VOD.

    Acceptable values: "Live", "Live-Linear", "DVR", "Catchup", "VOD".

    "c3.cm.channel" string The channel on which the content is consumed.

    Example: "ABC".

    "c3.cm.brand" string The name of the brand to which the content belongs.

    Examples: "ABC X", "ABC Y".

    "c3.cm.affiliate" string Affiliate or MVPD name for TV Everywhere authenticated services.

    Examples: "Xfinity", "Comcast".

    "c3.cm.categoryType" string

    Content business categories of interest.

    Use this constant to assign content category labels, such as Audio, Trailer, Tile Play, or Short Video.

    Examples: "Episodic", "Movies", "News", "Sports", "Events", "Informercials", "Shorts", "Promos", "Audio", "Tile Play", "Short Videos", "Trailer".

    "c3.cm.name" string Name of CMS Provider.

    Examples: "CMS", "ROVI", "TMS".

    "c3.cm.id" string Unique asset identifier to query CMS system to gather additional asset metadata information for a specific asset.

    Example: "003b094d-fc5c-3d5a-8ed0-301bf848291e".

    "c3.cm.seriesName" string The name of Series. Set the value only if the metadata cannot be gathered from CMS System. Null if not applicable.

    Examples: "Friends", "Null".

    "c3.cm.seasonNumber" string The Season number. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.

    Examples: "1", "Null".

    "c3.cm.showTitle" string The name of the Episode or Show Title. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.

    Examples: "The One with All the Cheesecakes", "Null".

    "c3.cm.episodeNumber" string The Episode number. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.

    Examples: "3", "Null".

    "c3.cm.genre" string The Primary content genre. Set the value only if the details cannot be inferred from Asset Provider Server. Null if not applicable.

    Examples: "Drama", "Null".

    "c3.cm.genreList" string The list of the applicable content genre. Set the values in a comma separated list only if the details cannot be inferred from Asset Provider Server. Null if not applicable.

    Examples: "Drama, Crime, Political, Violence", "Null"

    "c3.cm.utmTrackingUrl" string Provide the UTM parameters in the URL to track the effectiveness of the online marketing campaign across traffic sources and publishing media. Conviva uses CONTAINS logic to parse the individual UTM parameters from the URL provided, so either the full URL or just the UTM parameters is acceptable.


    Example values: http://www.example.com/?utm_source=newsletter1&utm_medium=email&utm_campaign=summer-sale&utm_content=toplink or utm_source=newsletter1&utm_medium=email&utm_campaign=summer-sale&utm_content=toplink

    This tag is only applicable for web and mobile devices.

    Custom Metadata

    Refer to App Manager->Setup Metadata page for your account to find the custom tags which shall be implemented.

    Set custom tags in a similar way for video, by adding the tags to the contentInfo object, passed into corresponding methods of ConvivaUWP.WinClient object.

    Conviva recommends to label the custom tags as "MyCustomTag1" or "my_custom_tag", and not use the c3.cm format, for instance, c3.cm.MyCustomTag1. Conviva reserved the c3.cm naming convention for the pre-defined or required metadata.

    Update/Amend Metadata

    To update or amend pre-defined and custom tags for video, use ConvivaUWP.WinClient.updateContentInfo(this.sessionId, contentInfo):

    • sessionId: previously referenced sessionId during createSession call.

    • contentInfo: map containing the key - value pairs of metadata tags for video content.

    Refer to the below example of setting pre-defined and custom metadata for video:

    // Fetch metadata from CMS and pass non-null values to Conviva
    // WinContentInfo Metadata Creation Block
    var  contentInfo = new ConvivaUWP.WinContentInfo();
    
    // required: unique value for every asset
    if (assetName != null) {
    contentInfo.setAssetName(assetName);
    }
    // highly recommended: dictionary of your custom metadata key/value string pairs
    for (var key in customMetadata) {
    var value  = customMetadata[key];
    if (key != null && value != null){
    contentInfo.setTag(key, value);
    }
    }
    // required: e.g. "http://your.cdn.com/stream.m3u8"
    if (streamURL != null){
    contentInfo.setStreamURL(streamURL);
    }
    // required: 1 for live content, 0 for VOD content
    if (isLive == 1 || isLive == 0){
    contentInfo.setIsLive(isLive);
    }
    // required: e.g. "Windows10 UWP JavaScript App"
    if (playerName != null) {
    contentInfo.setPlayerName(playerName);
    }
    // required for Viewers Module: e.g. "john@doe.com" or "12345"
    if (viewerId != null) {
    contentInfo.setViewerId(viewerId);
    }
    // optional: needed when the content's stream URL patterns
    // are not sufficient to identify the CDN
    if (defaultCDN != null) {
    contentInfo.setDefaultCDN(defaultCDN);
    }
    //optional: needed when the content length is accurately
    //present with application
    if(contentLength != null) {
    contentInfo.setDuration(contentLength);
    }
    
    ConvivaUWP.WinClient.updateContentInfo(this.sessionId, contentInfo);
    

    IMPORTANT: Please note that different Conviva products, such as Conviva VSI and Conviva Viewer Insights may have different logic with respect to handling updated values. Conviva recommends to update the metadata only when it is available and do not set any default values before the metadata is available.

    Ad Events and Metadata

    Report Ad Break

    An ad break is a single or a sequence of ads in the video stream. We are able to record ad break metadata like: planned ad break duration (podDuration), ad break position (podPosition), relative ad break index (podIndex) and absolute ad break index (absoluteIndex). To collect the ad break metadata, notify Conviva of the start and end of an ad break.

    Refer to the code examples below for Monitoring Ad Breaks:

    // Sample Event for Ad Pod Start
    var podStart = new Windows.Foundation.Collections.StringMap();
    podStart.insert("podDuration", "60");
    podStart.insert("podPosition", "Pre-roll");
    podStart.insert("podIndex", "1");
    podStart.insert("absoluteIndex","1");
    //SessionId should be valid
    ConvivaUWP.WinClient.sendEvent(sessionId, "Conviva.PodStart", podStart);
    
    // Sample Event for Ad Pod End
    var podEnd = new Windows.Foundation.Collections.StringMap();
    podEnd.insert("podPosition", "Pre-roll");
    podEnd.insert("podIndex", "1");
    podEnd.insert("absoluteIndex","1");
    //SessionId should be valid
    ConvivaUWP.WinClient.sendEvent(sessionId, "Conviva.PodEnd", podEnd);
    

    Pause Content Monitoring

    If you have content with ads, please review the steps in Pause Content Monitoring below. These steps are not needed if you do not have ads in your video content.

    The following step is required when the video content contains pre-roll and mid-roll ads.

    Handling Pre-Rolls

    A common way to handle pre-roll ads is to preload the main content, pause it while the pre-roll ad plays, and then resume the main content after the pre-roll completes. Essentially, the ad plays while the main content is loaded. However, you don't want the play time for the ad to be counted as part of the Video Startup Time metric, nor do you want to be constantly polling the player while the ad runs.

    The solution is to notify the Conviva layer of the pre-roll's existence and its start and end events.

    // As soon as ad playback starts, add these two calls
    ConvivaUWP.WinClient.adStart( sessionId ); // Signal the start of ad, so ad time can be calculated
    ConvivaUWP.WinClient.detachJSNotifier( sessionId ); // Pause monitoring while ad is playing
    
    // Call after ad ends and is about to transition to main content
    ConvivaUWP.WinClient.adEnd( sessionId ); // Signal the end of ad, so ad time can be calculated
    ConvivaUWP.WinClient.attachJSNotifier( sessionId, jsNotifier );  // Attach main content jsNotifier for monitoring
    

    Handling Mid-Rolls

    Ads played during the viewing of content are another case that needs to be handled correctly to maintain the accuracy of viewing metrics. For example, you don't want time spent viewing an ad to be included in buffering ratio calculations. Likewise, your metrics would also be adversely affected by ending a session when an ad starts and starting a new session when it resumes.

    The solution is to pause monitoring when the main content stops and a mid-roll ad starts. To resume the session, you attach either the same player instance or a new player instance when the ad stops.

    // As soon as the content stops playing, call:
    ConvivaUWP.WinClient.detachJSNotifier( sessionId );
    
    // Once the ad stops playing, resume the session by attaching the new player instance:
    ConvivaUWP.WinClient.attachJSNotifier( sessionId, jsNotifier );
    
    The jsNotifier instance can be a new instance or the same one that was used to create the session. However, it should not be null.

    3. Report Events and Metadata

    Report Playback Start

    The main purpose of Conviva Integration is to measure the quality of experience by monitoring videos from the moment user initiates playback. Use the following method create session to monitor video playback:

    • contentInfo: object carries on metadata associated with the video playback.

    • jsNotifier: wrap the player with a monitoring proxy videoElementStreamerProxy.GetJSNotifier();

    The keys / methods and expected values of the required metadata tags are defined in the Implement Metadata section below.

    IMPORTANT: ConvivaUWP.WinClient.createSession() API returns session ID which shall be stored till session lifecycle and shall be used for session specific API's.

    ConvivaUWPJS.VideoElementConvivaStreamerProxy is provided in the JS library to get important metrics from the

    function playVideo() {
    
    this.player = document.getElementById("video_player");
    
    // WinContentInfo Metadata Creation Block
    var contentInfo = new ConvivaUWP.WinContentInfo();
    
    // required: unique value for every asset
    if (assetName != null) {
    contentInfo.setAssetName(assetName);
    
    // Add the contentInfo as required
    ...
    
    
    // Wrap the player with a monitoring proxy
    this.videoElementStreamerProxy = new ConvivaUWPJS.VideoElementConvivaStreamerProxy( this.player );
    
    var jsNotifier = this.videoElementStreamerProxy.GetJSNotifier();
    
    // Create a monitoring session and keep a reference to its ID
    // Attach the JsNotifier from proxy to the monitoring session
    // WinClient.createSession() will return an integer 0 or greater
    // this.player is also known as streamer
    this.sessionId = ConvivaUWP.WinClient.createSession(contentInfo, jsNotifier);
    
    // Finish player initialization for mp4
    this.player.src = videoURL;
    
    // If you use AdaptiveMediaSource for HLS/DASH, your code should be similar to the following:
    //this.player.src = URL.createObjectURL(mediaSource, { oneTimeOnly: true });
    // Also media source has to be notified to streamer proxy in order to monitor HLS bitrate and errors.
    // this.videoElementStreamerProxy.setMediaSource(mediaSource);
    
    // If you want to remove media source from streamer proxy do this:
    //  this.videoElementStreamerProxy.cleanupMediaSource(mediaSource);
    
    }
    

    IMPORTANT: It's critical to make this API call correctly to monitor video experience - monitoring session created from this moment, and key metrics are captured based on this event. For example, if this call done late (say, when video starts rather than user clicks "play"), the Video Startup Time will be under-reported, Video Start Failures will be missed, etc.

    Please note that each video should be monitored separately - call this method for each new video played.

    IMPORTANT: If some of the content metadata tags aren't available at start, they can be set later or amended by ConvivaUWP.WinClient.updateContentInfo(this.sessionId, contentInfo); API - refer here for details. Please note, in most cases that it's required to set content metadata before the player reports "play" for the first time, to accurately attribute metadata to the video asset.

    Invoke createSession() On: Invoke cleanupSession() On:
    User clicks play button User stops the video User starts another video Video ends
    Video starts in autoplay mode
    User replays video again
    A new video starts in playlist Video item ends in playlist

    Report Playback Start with Deferred Streamer Attachment

    In certain scenarios, you create a video session but attach your player instance at a later stage, after checking for any errors that might occur after session creation but before streamer attachment. This is common when you use a DRM, when you create the player/streamer instance after a successful DRM validation. In such cases, you still create the monitoring session with its metadata as soon as the user has expressed intent to play the video (whether via auto-play or manually) but you attach your player/streamer instance via another method call, after manually reporting any errors that may have prevented successful playback. We count these errors with their corresponding messages - as Video Start Failures (VSFs).

    If you are using AdaptiveMediaSource for HLS/DASH (like in Microsoft example), before setting it as src to the

    Your code will look similar to:

    function playVideo() {
    // WinContentInfo Metadata Creation Block
    var contentInfo = new ConvivaUWP.WinContentInfo();
    
    // required: unique value for every asset
    if (assetName != null) {
    contentInfo.setAssetName(assetName);
    }
    
    // Add the contentInfo as required
    ...
    
    // Wrap the null player with a monitoring proxy
    this.videoElementStreamerProxy = new ConvivaUWPJS.VideoElementConvivaStreamerProxy(null);
    
    var jsNotifier = this.videoElementStreamerProxy.GetJSNotifier();
    
    // Create a monitoring session and keep a reference to its ID
    // LivePass.createSession() will return an integer 0 or greater
    // this.player is also known as streamer
    this.sessionId = ConvivaUWP.WinClient.createSession( contentInfo, jsNotifier );
    
    // Perform your extra logic (e.g., DRM check)
    ...
    
    // If a fatal error preventing playback is encountered,
    // report it manually and clean up the monitoring session
    if ( fatalErrorEncountered ) {
    ConvivaUWP.WinClient.reportError( this.sessionId, "Your error message", ConvivaUWP.WinErrorSeverity.fatal);
    ConvivaUWP.WinClient.cleanupSession( this.sessionId );
    return;
    } else {
    this.player = document.getElementById("video_player");
    
    // Detach the JS Notifier with null player
    ConvivaUWP.WinClient.detachJSNotifier( this.sessionId );
    
    // Wrap the player with a monitoring proxy
    this.videoElementStreamerProxy = new ConvivaUWPJS.VideoElementConvivaStreamerProxy(this.player);
    
    var jsNotifier = this.videoElementStreamerProxy.GetJSNotifier();
    
    // Attach the JsNotifier from proxy to the monitoring session
    ConvivaUWP.WinClient.attachJSNotifier( this.sessionId, jsNotifier);
    
    // Finish player initialization for mp4
    this.player.src = videoURL;
    
    // If you use AdaptiveMediaSource for HLS/DASH, your code should be similar to following
    //this.player.src = URL.createObjectURL(mediaSource, { oneTimeOnly: true });
    // Also media source has to be notified to the streamer proxy
    //in order to monitor HLS/DASH bitrate and errors.
    // this.videoElementStreamerProxy.setMediaSource(mediaSource);
    
    // If you want to remove media source from the streamer proxy do this:
    // this.videoElementStreamerProxy.cleanupMediaSource(mediaSource);
    }
    }
    

    Report Playback End

    Report end of playback by using the method:

    ConvivaUWP.WinClient.cleanupSession( sessionId );
    sessionId = -1;
    // Don’t forget to cleanup streamer proxy instance.
    videoElementStreamerProxy.Cleanup();
    videoElementStreamerProxy = null;
    
    After integrating the video player, review advanced use cases such as live program and playlist changes, fatal errors, and foreground and background actions that can be applicable for specific goals.

    Implement Advanced Metadata and Events

    Set Bitrate

    HLS/DASH with AdaptiveMediaSource

    HTML5

    // Wrap the player with a monitoring proxy
    this.videoElementStreamerProxy = new ConvivaUWPJS.VideoElementConvivaStreamerProxy( this.player );
    
    // Link to an AdaptiveMediaSource
    this.videoElementStreamerProxy.setMediaSource( adaptiveMediaSource );
    

    If you change the AdaptiveMediaSource during playback, the following code is required to keep monitoring the right instance:

    // Remove link to the old AdaptiveMediaSource
    this.videoElementStreamerProxy.cleanupMediaSource();
    
    // Link to a new AdaptiveMediaSource
    this.videoElementStreamerProxy.setMediaSource( newAdaptiveMediaSource );
    

    HLS/DASH without AdaptiveMediaSource

    To report bitrates for an HLS stream when you are not using the AdaptiveMediaSource class, use the setBitrate API as described below. Bitrate set by application will take precedence over Conviva auto-detected values.

    Smooth Streaming

    For MP4 and Smooth Streaming, the Conviva library does not automatically detect the display or playing bitrate due to a limitation of Windows UWP/Smooth Streaming Client SDK API. To report bitrate information from another source, use the setBitrate API, as follows:

    //set new bitrate and send the bitrate change event.
    ConvivaUWP.WinClient.setBitrate(this.sessionId, this.bitrate);
    
    For Smooth Streaming, the playing bitrate is defined as the total playing bitrate, including both audio and video tracks.

    Report Seek Events

    Fatal errors are any events preventing the user from seeing the video they attempted to play or any non-user event that causes midstream video playback failure (after the video starts successfully). These fatal errors should be reported and will be used to calculate Video Playback Failures (VPF) and Video Start Failures (VSF) metrics in Conviva VSI.

    Sample code for DRM Error reporting

    int sessionId = ConvivaUWP.WinClient.createSession( contentInfo );
    
    // The DRM errors can be reported via:
    ConvivaUWP.WinClient.reportError( this.sessionId, "errMessage", ConvivaUWP.WinErrorSeverity.fatal );
    
    // followed by cleaning up the session:
    ConvivaUWP.WinClient.cleanupSession( this.sessionId );
    
    // If no error occurs, the player instance will be created as usual and jsNotifier should be attached
    // to the session with this call:
    ConvivaUWP.WinClient. attachJSNotifier( this.sessionId, jsNotifier );
    

    Exception Handling

    For API calls from the ConvivaUWP namespace, the Conviva library silently suppresses underline exceptions from the DLL library. For the JavaScript library API calls from the ConvivaUWPJS namespace, you may want to catch these calls to troubleshoot your Conviva integration.

    try {
    this.videoElementStreamerProxy = new ConvivaUWPJS.VideoElementConvivaStreamerProxy(this.player);
    } catch (e) {
    customLogMyErrors(e); // pass exception object to error handler
    }
    

    Report CDN Server IP

    The Conviva WinJS library depends on the application to report CDN server IP. When the CDN Server IP is available to the application, the same can be reported to Conviva. The CDN Server IP is of type String and is set as attribute of the ConvivaUWP.WinClient class, which provides the following method.

    ConvivaUWP.WinClient.setCDNServerIP(sessionId, newCDNServerIP);
    

    The following code sample reports CDN Server IP to the Conviva WinJS library:

    // Report the CDN Server IP:
    // sessionId is Session ID for given session
    // cdnserverip is the CDN Server IP available with application
    ConvivaUWP.WinClient.setCDNServerIP(sessionId, cdnserverip);
    

    Report Dropped Frames Count

    The dropped frames count for a specific interval is reported periodically. The Conviva WinJS library depends on the application to report the dropped frames count. The dropped frames count is of the type Integer and is set as an attribute of the ConvivaUWP.WinClient class, which provides the following method:

    ConvivaUWP.WinClient.setDroppedFrameCount(sessionId, droppedFrameCount);
    

    The following code sample reports the dropped frames count to the Conviva WinJS library:

    // Report the dropped frames count:
    // sessionId is Session ID for the given session
    // droppedFrameCount is the number of frames dropped by the player since last reported
    ConvivaUWP.WinClient.setDroppedFrameCount(sessionId, droppedFrameCount);
    

    4. Handle User Actions

    Report Network Metrics

    The Conviva library automatically detects the network connection type only for Windows 10 devices (Ethernet, WiFi, 3G, OTHER). The Conviva library reports the raw values returned by the WWAN network connection data service class.

    Use the following Conviva mapping to reference the raw values:

    Raw Value Mapping
    WiFi WiFi
    Cdma1xEvdo 3G
    Cdma1xEvdoRevA 3G
    Cdma1xEvdoRevB 3G
    Cdma1xEvdv 3G
    Cdma1xRtt 3G
    Cdma3xRtt 3G
    CdmaUmb 3G
    Edge 2G
    Gprs 2G
    Hsdpa 3G
    Hsupa 3G
    LetAdvanced 4G
    Umts 2G
    Custom Other
    Connection Type will be detected after session creation, before the first video frame is rendered.

    Report Custom Events

    Player Insight is an advanced feature which allows you to track custom events that are not related to video rendering, but rather specific to your player's functionality. These events and their attributes are then tabulated in the Player Insight dashboard at Conviva VSI (Pulse). Contact your Conviva representative to enable Player Insights in Pulse.

    You may send a custom Player Insight event that can be associated with a video playback using the following method:

    Report video-related events by the method ConvivaUWP.WinClient.sendEvent(this.sessionId, eventName, /* Windows.Foundation.Collections.StringMap */ stringMap):

    Following is an example of a custom event named "TestEvent", with two attributes:

    // prepare the eventAttributes parameter:
    var stringMap = new Windows.Foundation.Collections.StringMap();
    // loop over key/value pairs
    stringMap.insert(“attr1”, “value1”);
    stringMap.insert(“attr2”, “value2”);
    
    ConvivaUWP.WinClient.sendEvent(sessionId, “TestEvent”, stringMap);
    

    You may send a custom Player Insight event specific to your player's functionality, but not associated with a monitoring session by passing "0" (integer) for sessionId:

    ConvivaUWP.WinClient.sendEvent(0, "TestEvent", stringMap);
    

    5. Clean Up Session

    Each monitoring session needs to be cleaned up once the video stream it's attached to is no longer used. Depending on how the app/player is set up, this step may occur at the end of playback, during player deallocation, or before transitioning to a different stream.

    The method signature is:

    ConvivaUWP.WinClient.cleanupSession( sessionId );
    sessionId = -1;
    // Don’t forget to cleanup streamer proxy instance.
    videoElementStreamerProxy.Cleanup();
    videoElementStreamerProxy = null;
    

    Advanced Use Cases

    You can use specific APIs in the Conviva sensor for various advanced use cases, such as:

    • Live or live linear streaming program changes
    • Video changes in the playlist
    • Playback does not recover from error and is reported once only
    • Multiple errors due to retrying when playback does not recover
    • Playback recovers from a fatal error by switching to a different asset URL or CDN
    • A warning occurs when there's no impact on the playback
    • Handling user actions, such as user dialogues

    To learn more about these advanced use cases, see here.

    Limitations

    Metric Name Impact Conditions Issue
    Average Bitrate Under-reported HLS/DASH HTML5
    Not reported Smooth Streaming (SS) Smooth Streaming SDK doesn't report bitrate for SS streams. Please update the stream bitrate manually using the guidelines under Set Bitrate section.
    Average Frame Rate Not reported All Player doesn't support an API to fetch frame rate information.
    Average % Complete Over-reported Background The player reports PLAYING state even when the application is in the background or sleep-mode or the device is locked.
    Minutes/Unique Device Over-reported Background The player reports PLAYING state even when the application is in the background or sleep-mode or the device is locked.
    Minutes/Ended Play Over-reported Background The player reports PLAYING state even when the application is in the background or sleep-mode or the device is locked.
    Total Minutes Over-reported Background The player reports PLAYING state even when the application is in the background or sleep-mode or the device is locked.
    Metadata Name Impact Conditions Issue
    Device Type Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Browser Name Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Browser Version Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Device Manufacturer Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Device Name Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Device Marketing Name Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Device Hardware Type Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Device Operating System Not reported All The player doesn't support User Agent String (UAS), where this metadata would be collected from.
    Framework Version Not-reported First heartbeat The player doesn't provide Framework Version.
    Device Connection Type Not-reported Xbox Device Connection Type is not detected on an Xbox device.
    Link Encryption Not-reported Xbox Link Encryption is not detected on an Xbox device.
    Screen Resolution Not-reported Xbox Screen resolution is not detected on Xbox devices.

    Self Validation

    Upon completion of your integration, and before submission to Conviva QA team, developers should complete a comprehensive self-validation test pass of each Device Application.

    Perform self-validation of video sensor integration using Touchstone in Pulse.

    Conviva provides sample test cases with detailed steps and expected results.

    Developers should be checking for both metric and metadata accuracy. Based on our experience, comprehensive self-validation can reduce your QE cycles, saving your costly project time.