-
Notifications
You must be signed in to change notification settings - Fork 17
/
subtitle.html
76 lines (76 loc) · 2.47 KB
/
subtitle.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no"
/>
<title>COS 音视频</title>
<link
href="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.1/tcplayer.min.css"
rel="stylesheet"
/>
<!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.v4.2.min.js 之前引入 hls.min.0.13.2m.js。-->
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.1/libs/hls.min.0.13.2m.js"></script>
<!--播放器脚本文件-->
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.0/tcplayer.v4.5.0.min.js"></script>
<style>
html,
body {
margin: 0;
padding: 0;
overflow: hidden;
height: 100%;
}
.tcplayer {
margin: 0 auto;
width: 100%;
height: 100%;
}
.vjs-text-track-display div {
font-size: 14px!important;
}
</style>
</head>
<body>
<!-- 设置播放器容器 -->
<video
id="player-container-id"
preload="auto"
width="100%"
height="100%"
playsinline
webkit-playsinline
></video>
<!--
注意事项:
* 播放器容器必须为 video 标签
* player-container-id 为播放器容器的ID,可自行设置
* 播放器区域的尺寸请按需设置,建议通过 css 进行设置,通过css可实现容器自适应等效果
* playsinline webkit-playsinline 这几个属性是为了在标准移动端浏览器不劫持视频播放的情况下实现行内播放,此处仅作示例,请按需使用
* 设置 x5-playsinline 属性会使用 X5 UI 的播放器
* 右键点击视频画面可选镜像
-->
<script>
var player = TCPlayer('player-container-id', {});
player.src(
'https://cos-video-1258344699.cos.ap-guangzhou.tencentcos.cn/test.mp4'
);
player.on('ready', function () {
// 添加字幕文件
var subTrack = player.addRemoteTextTrack(
{
src: 'https://cos-video-1258344699.cos.ap-guangzhou.myqcloud.com/subtitle/zh.srt',
kind: 'subtitles',
srclang: 'zh-cn',
label: '中文',
default: 'true',
},
true
);
});
</script>
</body>
</html>