From 504e27bd5a95b2740fc82679bef6f605eaa148d6 Mon Sep 17 00:00:00 2001
From: xc <double72cheng@gmail.com>
Date: Tue, 20 Apr 2021 15:06:44 +0800
Subject: [PATCH] 直播与回放分布
---
src/main/resources/public/index3.html | 264 +++++++++++++++++++++++-----------------------------
1 files changed, 118 insertions(+), 146 deletions(-)
diff --git a/src/main/resources/public/index3.html b/src/main/resources/public/index3.html
index 42c36b3..be49aca 100755
--- a/src/main/resources/public/index3.html
+++ b/src/main/resources/public/index3.html
@@ -5,43 +5,12 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Jessibuca 1.0</title>
<meta charset="utf-8"/>
+ <link rel="stylesheet" href="css/font-awesome.min.css">
+ <link rel="stylesheet" href="css/controles.css">
+ <link rel="stylesheet" href="css/progressTime.css">
+
+
<style>
- .btn {
- display: inline-block;
- line-height: 1;
- white-space: nowrap;
- cursor: pointer;
- -webkit-appearance: none;
- text-align: center;
- box-sizing: border-box;
- outline: none;
- margin: 0;
- transition: .1s;
- font-weight: 500;
- -moz-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- padding: 12px 20px;
- font-size: 14px;
- border-radius: 4px;
- color: #fff;
- background-color: #409eff;
- border-color: #409eff;
- width: 100%;
- }
-
- .btn-danger {
- color: #fff;
- background-color: #f56c6c;
- border-color: #f56c6c;
- }
-
- .btn-success {
- color: #fff;
- background-color: #67c23a;
- border-color: #67c23a;
- }
-
.player-wrapper {
width: 900px;
height: 500px;
@@ -50,65 +19,72 @@
text-align: center;
}
- .btn-wrapper {
- width: 900px;
- height: 50px;
- margin: 0 auto;
- margin-top: 10px;
- }
+ /* .player-wrapper canvas {
+ width: 100%;
+ height: 100%;
+ }*/
- /*.player-wrapper canvas {
- width: 100%;
- height: 100%;
- }*/
-
- .logs {
- border: 1px solid #333;
- width: 900px;
- height: 300px;
- margin: 0 auto;
- overflow-y: auto;
- padding: 5px;
- }
</style>
</head>
<body>
-<div class="player-wrapper" id="container" style="background-color: #0D0E1B;width:900px;height:500px">
-</div>
-<div class="btn-wrapper" id="playDom">
- <button class="btn" id="play">播放</button>
-</div>
-<div class="btn-wrapper btn-wrapper2" id="stopDom" style="display: none">
- <div style="margin-top: 5px">
- <button class="btn btn-danger" id="stop">结束</button>
+
+<!-- jessiebuca播放器 -->
+<div class="wrap">
+ <div class="content">
+ <div class="player" onmouseover="playerShow()" onmouseout="playerHidden()">
+ <div class="player-wrapper" id="container" style="background-color: #0D0E1B;">
+ </div>
+ <div class="control">
+
+ <div class="fa fa-play" id="play">
+ </div>
+ <div class="fa fa-stop" id="stop" style="display: none">
+ </div>
+
+ <div>
+ <span class="progress"></span>
+ </div>
+ <div class="timer">
+ <span class="progress_timer">00:00:00</span>/
+ <span class="duration_timer">00:00:00</span>
+ </div>
+ <div class="fa fa-expand expand" onclick="h5lc.fullscreen=true"></div>
+ </div>
+ </div>
</div>
</div>
-<button class="btn" onclick="h5lc.fullscreen=true">全屏</button>
-<div id="logout" class="logs">
-</div>
-<script src="./ajax.js"></script>
-<script src="./renderer.js"></script>
-<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
+<div id="progressTime"></div>
+
+
+<script src="./js/ajax.js"></script>
+<script src="./js/renderer.js"></script>
+<script type="text/javascript" src="./js/jquery.min.js"></script>
+<script type="text/javascript" src="./js/jquery.progressTime.js"></script>
+
<script>
- onerror = handleErr;
- var txt = "";
+ var hourTimestamp = 3600 * 1000;
+ var dayTimestamp = hourTimestamp * 24;
+ var currentTimer;
+
+
window.onkeydown = function () {
h5lc.fullscreen = false
}
var $play = document.getElementById('play');
var $stop = document.getElementById('stop');
- var $playDom = document.getElementById('playDom');
- var $stopDom = document.getElementById('stopDom');
var container = document.getElementById("container");
+ var $progressTime = document.getElementById('progressTime');
+
var isPlaying = false;
- disabledMouseWheel(container);
let stream = queryParam('stream') || 'user1';
let decoder = queryParam('decoder') || 'ff';
let source = queryParam('source') || 'localhost';
+
var h5lc = new Jessibuca({container, decoder: decoder + ".js", videoBuffer: 0});
+
h5lc.onLoad = function () {
//this.play("wss://pulls.1234326.cn/live/L01.flv")
@@ -119,72 +95,45 @@
}
h5lc.onPlay = function () {
isPlaying = true;
- $playDom.style.display = 'none';
- $stopDom.style.display = 'block';
+ $play.style.display = 'none';
+ $stop.style.display = 'inline';
}
$play.addEventListener('click', function () {
if (isPlaying) {
return;
}
isPlaying = true;
-/* $.get("http://127.0.0.1:8088/monica/test/video", function (data) {
- h5lc.play(data)
- }
- );*/
+ /* $.get("http://127.0.0.1:8088/monica/test/video", function (data) {
+ h5lc.play(data)
+ }
+ );*/
play();
- $playDom.style.display = 'none';
- $stopDom.style.display = 'block';
+ $play.style.display = 'none';
+ $stop.style.display = 'inline';
}, false);
$stop.addEventListener('click', function () {
if (!isPlaying) {
return;
}
-
isPlaying = false;
+ //stop();
+
+ $play.style.display = 'inline';
+ $stop.style.display = 'none';
+ }, false);
+
+
+ function play(firstResponseIp) {
+ h5lc.play("ws://172.16.30.113:8082/live/video4.flv")
+ }
+
+ function stop() {
$.get("http://127.0.0.1:8088/monica/video/stop?param=live/test", function () {
alert("视频流已关闭");
h5lc.close()
}
);
- //stop();
-
- $playDom.style.display = 'block';
- $stopDom.style.display = 'none';
- }, false);
-
-
- function play(firstResponseIp) {
- //h5lc.play("ws://" + (firstResponseIp || source) + ":8080/live/" + stream)
- //h5lc.play("ws://pull2.afb1188.com/live/" + stream + ".flv")
- //h5lc.play("ws://localhost:8080/live/" + stream)
- h5lc.play("ws://172.16.30.113:8082/live/video3.flv")
- //h5lc.play("ws://localhost:8072/live/test.flv")
- // h5lc.play("ws://119.9.118.39:8080/live/user1", canvas)
- // h5lc.play("ws://test.qihaipi.com/gnddragon/test.flv", canvas)
- // h5lc.play("ws://localhost:8080/live/test.flv", canvas)
-
- }
-
- function getFastCdnFromList(ipList) {
- ipList = ipList || [];
- var firstResponseIp = '';
-
- for (var i = 0, len = ipList.length; i < len; i++) {
- var tempIp = ipList[i].name;
- var reqHref = 'http://' + tempIp + '/test';
- var request = _ajax.get(reqHref);
- request.then(function (data) {
- if (!firstResponseIp) {
- firstResponseIp = tempIp;
- // 直接可以播放了。
- play(firstResponseIp);
- }
- })
- }
- }
-
- function stop() {
h5lc.close()
}
@@ -220,35 +169,58 @@
}
}
- function disabledMouseWheel(ele) {
- if (ele.addEventListener) {
- ele.addEventListener('DOMMouseScroll', scrollFunc, false);
- } //W3C
- ele.onmousewheel = scrollFunc; //IE/Opera/Chrome
+ function playerShow() {
+ $(".player .control").css("display", "block")
}
- function scrollFunc(evt) {
- evt = evt || window.event;
- if (evt.preventDefault) {
- // Firefox
- evt.preventDefault();
- evt.stopPropagation();
- } else {
- // IE
- evt.cancelBubble = true;
- evt.returnValue = false;
+ function playerHidden() {
+ $(".player .control").css("display", "none")
+ }
+
+
+ $("#progressTime").ProgressTime({
+ container: "progressTime",
+ startTime: new Date(formatDate(new Date(new Date().getTime() - dayTimestamp * 3), "YYYY/MM/DD 00:00:00")),
+ endTime: new Date(formatDate(new Date(), "YYYY/MM/DD 00:00:00")),
+ currentTime: new Date(formatDate(new Date(new Date().getTime() - dayTimestamp * 2), "YYYY/MM/DD 12:00:00")),
+ interval: 300,
+ delay: 2000,
+ isNow: false, // 是否显示右侧回到当前时间
+ toPlay: false, // 渲染是否完成
+ animateFinish: false, // 动画是否完成
+ callback: function (config) {
+ console.log(config);
+ currentTimer = config.time;
+ },
+ animateCallback: function (config) {
+
+ // 假如动画完成之后请求数据需要两秒
+ var timer = setTimeout(function () {
+ progressTime.options.toPlay = true; // 两秒之后再继续走播放条
+ clearTimeout(timer);
+ }, 0);
}
- return false;
- }
+ });
+ $(".progressTime-left-b-start").on("click", function () {
+ if (currentTimer) {
+ $(this).addClass("stop");
- function handleErr(msg, url, l) {
- txt = "There was an error on this page.\n\n";
- txt += "Error: " + msg + "\n";
- txt += "URL: " + url + "\n";
- txt += "Line: " + l + "\n\n";
- document.getElementById("logout").innerHTML += txt + "<br>";
- return true;
- }
+ $.ajax({
+ url: "" + "?param=",
+ async: false,//同步方式发送请求,true为异步发送
+ type: "GET",
+ data: {},
+ success: function (result) {
+ alert(result);
+ }
+ });
+
+ }
+ });
+ $(".progressTime-left-b-start stop").on("click", function () {
+ $(this).removeClass("stop");
+ });
+
</script>
</body>
--
Gitblit v1.9.1