Getting Started with Brightcove Web & Smart TV SDK
Installing the SDK
You can install the Brightcove Web & Smart TV SDK using npm or directly from the Brightcove CDN.
Using npm:
Open your command line interface and run the following command to install the SDK:
npm install @brightcove/web-sdk
Using CDN:
Alternatively, if you prefer to use the SDK from the CDN, include the following script tag in your HTML files:
<script src="https://players.brightcove.net/web-sdk/1/index.js"></script>
Creating a Media Player
Once the SDK is installed, you can create a media player to embed in your application. By following these steps, you will have a basic video player set up using the Brightcove Web & Smart TV SDK.
-
Import the Player (with UI) class from the Brightcove SDK:
import { Player } from '@brightcove/web-sdk';
-
Create a Player Instance:
const player = new Player();
-
Set up the player with your Brightcove account details:
player.updateConfiguration({ brightcove: { accountId: 'your-account-id', auth: { policyKey: 'your-policy-key' } } });
-
Link the player to a video element:
const videoElement = document.querySelector('video'); player.attach(videoElement);
-
Load a video by its ID from the Brightcove Playback API:
const { promise } = player.getVideoById({ videoId: 'your-video-id' }); promise.then((videoModel) => player.loadVideoModel(videoModel));
// Import the Player (with UI) class from the Brightcove SDK
import { Player } from '@brightcove/web-sdk';
// Create a new player
const player = new Player();
// Update the player's configuration
player.updateConfiguration({
brightcove: {
accountId: 'your-account-id',
auth: { policyKey: 'your-policy-key' }
}
});
// Attach a video element to the Player instance
const videoElement = document.querySelector('video');
player.attach(videoElement);
// Load a video by its ID from the Brightcove Playback API
const { promise } = player.getVideoById({ videoId: 'your-video-id' });
promise.then((videoModel) => player.loadVideoModel(videoModel));