-
Notifications
You must be signed in to change notification settings - Fork 63
/
index.ts
55 lines (48 loc) · 1.66 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Player, PlayerConfig, SourceConfig } from "bitmovin-player";
import { UIFactory } from "bitmovin-player-ui";
import { CmcdConfig, CmcdIntegration, CustomKey } from "@bitmovin/player-web-integration-cmcd";
import { v4 as uuidv4 } from 'uuid';
const playerConfig: PlayerConfig = {
key: '7e9c8483-ea84-423e-b675-19cf31dec43a',
playback: {
autoplay: true,
muted: true,
},
ui: false,
};
const cmcdConfig: CmcdConfig = {
useQueryArgs: true,
sessionId: uuidv4(),
contentId: '1111-111111-111111-11111',
customKeys: [
new CustomKey('com.example-player_name', 'bitmovin-player'),
]
};
const cmcdIntegration = new CmcdIntegration(cmcdConfig);
playerConfig.network = {
preprocessHttpRequest: cmcdIntegration.preprocessHttpRequest,
preprocessHttpResponse: cmcdIntegration.preprocessHttpResponse as any,
}
playerConfig.adaptation = {
desktop: {
onVideoAdaptation: cmcdIntegration.onVideoAdaptation,
onAudioAdaptation: cmcdIntegration.onAudioAdaptation,
},
mobile: {
onVideoAdaptation: cmcdIntegration.onVideoAdaptation,
onAudioAdaptation: cmcdIntegration.onAudioAdaptation,
},
}
const sourceConfig: SourceConfig = {
title: 'Art of Motion',
hls: 'https://cdn.bitmovin.com/content/assets/streams-sample-video/tos/m3u8/index.m3u8',
};
const htmlContainer = document.getElementById('playerContainer');
if (!htmlContainer) {
throw new Error('No HTMLElement with ID `player` found.');
}
const player = new Player(htmlContainer, playerConfig);
const uimanager = UIFactory.buildDefaultUI(player);
cmcdIntegration.setPlayer(player);
cmcdIntegration.setSessionId((player as any).analytics.getCurrentImpressionId());
player.load(sourceConfig);