# 14.http-flv.js实战
# 相关代码
# index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>flv.js演示</title>
<script src="./flv.js" charset="utf-8"></script>
</head>
<body>
<video id="videoElement" width="400" height="200" controls></video>
<script src="./index.js" charset="utf-8"></script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# index.js
var flvjs = window.flvjs;
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'http://xhalive.qwmedia.cn/hdratv-live/xha-xwpd.flv'
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
← 13.hls.js实战 15.H5直播总结 →