This commit is contained in:
2025-08-07 02:21:30 +08:00
commit 3f67c118de
13 changed files with 1024 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>简易流播放器</title>
<link href="https://vjs.zencdn.net/8.6.0/video-js.css" rel="stylesheet">
<script src="https://vjs.zencdn.net/8.6.0/video.min.js"></script>
</head>
<body>
<h3>流播放器</h3>
<input type="text" id="streamId" value="mystream" placeholder="输入流ID">
<button onclick="startPlay()">开始播放</button>
<div style="margin-top: 20px;">
<video id="player" class="video-js vjs-default-skin" controls width="800" height="450"></video>
</div>
<script>
let player = null;
function startPlay() {
const streamId = document.getElementById("streamId").value;
const playUrl = `/stream/${streamId}`;
// 销毁现有播放器
if (player) {
player.dispose();
}
// 创建新播放器
player = videojs('player', {
autoplay: true,
controls: true,
sources: [{
src: playUrl,
type: 'application/x-mpegURL'
}]
});
}
</script>
</body>
</html>