You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.9 KiB
52 lines
1.9 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>flvjsdemo</title>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<input id="url" type="text" value="http://192.168.3.2:8080/live/b57e867ae29d11b483864cbd8fd0f747.flv" placeholder="url" style="width:80%;" /><button id="btn">播放</button>
|
|
</div>
|
|
<video id="videoElement" muted controls autoplay> style="width:80%;"></video>
|
|
<script>
|
|
var flvPlayer;
|
|
document.getElementById('btn').addEventListener('click', function () {
|
|
if (flvjs.isSupported()) {
|
|
var videoElement = document.getElementById('videoElement');
|
|
if (flvPlayer) {
|
|
flvPlayer.unload();
|
|
flvPlayer.detachMediaElement();
|
|
flvPlayer.destroy();
|
|
flvPlayer = null;
|
|
}
|
|
flvPlayer = flvjs.createPlayer({
|
|
type: 'flv',
|
|
url: document.getElementById('url').value,
|
|
isLive: true,
|
|
cors: true
|
|
}, {
|
|
isLive: true,
|
|
fixAudioTimestampGap: false,
|
|
enableWorker: true,
|
|
enableStashBuffer: false,
|
|
stashInitialSize: 1,
|
|
//lazyLoad: false,
|
|
//lazyLoadMaxDuration: 1,
|
|
//lazyLoadRecoverDuration: 1,
|
|
deferLoadAfterSourceOpen: false,
|
|
//autoCleanupMaxBackwardDuration: 1,
|
|
//autoCleanupMinBackwardDuration: 1,
|
|
//statisticsInfoReportInterval: 1,
|
|
});
|
|
flvPlayer.attachMediaElement(videoElement);
|
|
flvPlayer.load();
|
|
}
|
|
else {
|
|
alert('不支持flv格式');
|
|
}
|
|
});
|
|
</script>
|
|
<script src="/lib/flv.js/flv.min.js"></script>
|
|
</body>
|
|
</html> |