Companywebcast API Wiki

Page History: PlayerSDK 2.0 Getting Started

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2016/11/08 14:53


Table of Contents [Hide/Show]


      Embedding the Player
      Customizing playback
      Methods
      Event handling
       speakerResource
       topicResource
       event
      Using Chat


Embedding the Player

Embedding the Player involves:
loading a JavaScript library from Company Webcast servers
adding a DIV to your DOM that the Javascript library can fill with the Player
initializing the Player from Javascript.



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Player SDK Sample Application</title>
</head>
<body>
    <div id="playerContainer" style="width:640px;height:360px;"></div>
</body>
</html>

< script type="text/javascript" src="//sdk.companywebcast.com/sdk/player/client.js"></script>
< script type="text/javascript">

    var cwcPlayer = cwc.sdk.player.client.createPlayer({
        id: 'customer/code'
    });

    document.getElementById("playerContainer").appendChild(cwcPlayer.element);

</script>



Customizing playback

Players can be configured to start playback from a specific position.
Players can be configured to play a fragment, or a series of fragments, from a single Webcast.
Players can be configured to hide specific Player functionality and UI features.


Player initialization accepts the following parameters:

id
A string. This is the WebcastCode, or WebcastGuid that you have retrieved through other components of the Company Webcast API.
offsets
An array of integers. Expose only parts of the media stream. This is essentially virtual fragment generation. In milliseconds: [start, end, start, end].
start
An integer. In milliseconds, the position from where the Player will commence playback. The start property is applied after any configured offsets are applied.
identificationToken
A string. Allows for Single Signon scenarios.
display
A Bitwise OR. Configures which parts of the Player are visible.
Not setting this property will display all buttons.

Options are:
1
display home button
2
display topics button

< script type="text/javascript">

    var cwcPlayer = cwc.iframe.player.client.create({
        id: 'customer/code',
        start: 5000,
        offsets: [20000, 40000, 50000, 80000],
        display: 1 | 2
    });

</script>




Methods

An instance of the embedded player has 3 methods.

Available methods:

on
See Event handling
createChat
See Using Chat
seek
Accepts a seek object as its input parameter. The seek object has either the timestamp property, or the walltime property. Timestamps are an integer, in milliseconds. Walltimes are ISO DateTime strings. Media playback jumps to the given position.


< script type="text/javascript">

    cwcPlayer.seek({ timestamp: 5000 });
    cwcPlayer.seek({ walltime: '2007-03-01T13:00:00Z' });

</script>




Event handling

Event listeners can be attached to the embedded player, so events can be received for changes in metadata.

Available Events:

resource:create

Fires when a new resource is added to the model. This happens during initialization, when metadata is loaded into the player, and when new resources are added during a live Webcast.
Returns a resourceCreateEvent.

properties of resourceCreateEvent are:

playerId
A string. The id of the player instance that generated the event.
resource
Either a speakerResource, or a topicResource. The resource that was added to the model.


resource.state:change

Fires when a resource activates or de-activates.
Returns a resourceChangeEvent.

properties of resourceChangeEvent are:

playerId
A string. The id of the player instance that generated the event.
resource
Either a speakerResource, or a topicResource. The resource that was changed.
isActive
A boolean. If true, the resource is currently active.
view
A string. Either "current" or "live". The embedded player has DVR features, meaning users are able to pause and rewind a live stream. This is why the cwc.sdk.player.resource.properties.change event fires both when a resource changes on the current position in the timeline, and when a resource changes in the "live playhead". For most cases you would only be interested in events of the "current" view.


event:create

Fires when a new Event is added to the Player model.
Returns a eventCreateEvent.

properties of eventCreateEvent are:

event
An event. The event that was just created.
playerId
A string. The id of the player instance that generated the event.




< script type="text/javascript">

    cwcPlayer.on('resource:create', function (resourceCreateEvent) {

    });

    cwcPlayer.on('resource.state:change', function (resourceChangeEvent) {

    });

    cwcPlayer.on('event:create', function (eventCreateEvent) {

    });

</script>




speakerResource

Contains information about a speaker.

speakerResource has the following properties:

id
A string. The id of the resource. These map onto id's that you've retrieved from other components of the Company Webcast API.
namespace
A string. Contains "cwc.legacy.speaker".
order
An integer. If applicable, contains a number indicating the position of the resource in a list of resources of the same type.
category
A string. The category of the speaker. This may contain the political party of the speaker, or a company department, for example.
name
A speakerName object.
speakerName has the following properties:
title
A string. The title of the speaker.
first
A string. The first name of the speaker.
middle
A string. The middle name of the speaker.
last
A string. The last name of the speaker.
full
A string. The full name of the speaker.
role
A string. The role of the speaker.




topicResource

Contains information about a topic.

topicResource has the following properties:

id
A string. The id of the resource. These map onto id's that you've retrieved from other components of the Company Webcast API.
namespace
A string. Contains "cwc.legacy.topic".
order
An integer. If applicable, contains a number indicating the position of the resource in a list of resources of the same type.
label
A string. Contains the title of the topic.
description
A string. Present if available. Contains a description of the topic.




event

Contains an event. Events describe activation and de-activation of a resource.

event has the following properties:

eventData
A string.
id
A string. The id of resource this event describes.
intent
A string. Contains either "speakers.speaker:activate".
orderNr
An integer. If applicable, contains a number indicating the position of the event in a list of events of the same type.
target
A string. Contains the uri of the resource this event describes.
timestamp
An integer. In milliseconds; describes the playback position where this event activates/de-activates.




Using Chat

Some Webcasts may include Chat functionality. Chat widgets can be embedded using this SDK. Note that Chat is enabled on a per-Webcast basis, and is only available to customers who have specifically enabled this functionality. For Webcasts that have Chat enabled, please note that Chats are currently only available when a Webcast is LIVE. Webcasts either before or after the LIVE phase do not have access to Chat functionality.