Docs

Video Selection

Please feel free to create an issue if you have any questions not answered by this documentation.

Overview

The Smart Embed selection has been developed as a single page web application, designed to be implemented within your platform via two components; an Iframe and a small Events API JavaScript library.

Prerequisites

Before you begin, you should have obtained the following from ClickView:

Steps to select a video

1. Prompt a user to select a video

Our video selection should happen in an iframe embedded into your site. This Iframe displays an interface that allows signed in users to browse their videos and select the video which they wish to embed. Users will be required to either sign in or sign up, in order to select a video to embed.

Iframe example

Here is a simple example of an iframe linking to your web application.

<div style="padding: 56.25% 0 0 0; position: relative; border: 1px solid #eaeaea;">
  <iframe
    id="clickview-video-select"
    src="https://integrations.clickviewapp.com/smart-embed/select?clientId=YOUR_CLIENT_ID"
    style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
    frameborder="0"
  ></iframe>
</div>

Replace YOUR_CLIENT_ID with your actual Client ID.

NOTE: The div wrapping this iframe is optional, but provides an example of how to allow your iframe to display itself responsively.

2. Capture the selected video

In order to capture information about the user’s selected video, we have created a simple JavaScript API. When a user selects a video, an event will be triggered. Use ClickView’s CVEvents API to listen to this event in order to retrieve metadata about the selected video.

Loading in our CVEvents API

The CVEvents API is available on our CDN: https://static.clickview.com.au/cv-events-api/1.1.1/cv-events-api.min.js. Feel free to embed this directly into your platform like so.

<script src="https://static.clickview.com.au/cv-events-api/1.1.1/cv-events-api.min.js" type="text/javascript"></script>

Or alternatively you may download the file and host it directly from your platform.

Capturing a selected video event

To use the CVEventsApi, first create an instance passing in your iframe:

// your iframe markup
//<iframe id="clickview-video-select" ...></iframe>

const cvEventsApi = new CVEventsApi(document.getElementById('clickview-video-select').contentWindow);
cvEventsApi.on('cv-lms-addvideo', (event, details) => {
  // Your logic to save the mediaId here
});

Here is an example of a details object:

{
  title: 'Example video',
  thumbnailUrl: 'https://example.com/video-image.png',
  mediaId: '123456'
}

3. Save the selected mediaId

The mediaId which is returned on the details property of the cv-lms-addvideo event will be used by you to create a view key each time a user attempts to watch the selected video. You will need to store this selected mediaId.

Best practices

Next Steps

Once you have allowed your user to select a video, and saved the mediaId. You can move onto implementing Video Playback.