fix:温湿度操作记录日志、温湿度同步后台、删除查询日志、停止视频播放
This commit is contained in:
@ -27,6 +27,69 @@
|
||||
object-fit: contain; /* 保持视频比例,不变形 */
|
||||
}
|
||||
|
||||
/* 简化的控制按钮样式 */
|
||||
.control-buttons {
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
z-index: 999;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 25px;
|
||||
padding: 12px 20px;
|
||||
min-width: 100px;
|
||||
min-height: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.control-btn:active {
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.play-btn {
|
||||
background: rgba(76, 175, 80, 0.8);
|
||||
border-color: rgba(76, 175, 80, 0.9);
|
||||
}
|
||||
|
||||
.play-btn:active {
|
||||
background: rgba(76, 175, 80, 0.9);
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
background: rgba(33, 150, 243, 0.8);
|
||||
border-color: rgba(33, 150, 243, 0.9);
|
||||
}
|
||||
|
||||
.refresh-btn:active {
|
||||
background: rgba(33, 150, 243, 0.9);
|
||||
}
|
||||
|
||||
/* 按钮图标样式 */
|
||||
.btn-icon {
|
||||
margin-right: 6px;
|
||||
font-size: 16px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.btn-text {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.loading {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@ -56,11 +119,56 @@
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* 简化的暂停占位符样式 */
|
||||
.pause-placeholder {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 50%;
|
||||
background: #000000;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.pause-content {
|
||||
text-align: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.pause-title {
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="loading" id="loading">正在加载播放器...</div>
|
||||
<iframe id="player-iframe" allow="autoplay; fullscreen"></iframe>
|
||||
|
||||
<!-- 暂停时的占位符 -->
|
||||
<div class="pause-placeholder" id="pause-placeholder">
|
||||
<div class="pause-content">
|
||||
<div class="pause-title">监控已暂停</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 控制按钮 -->
|
||||
<div class="control-buttons" id="control-buttons" style="display: none;">
|
||||
<div class="control-btn play-btn" id="play-btn">
|
||||
<span class="btn-icon" id="play-icon">▶️</span>
|
||||
<span class="btn-text" id="play-text">播放</span>
|
||||
</div>
|
||||
<div class="control-btn refresh-btn" id="refresh-btn">
|
||||
<span class="btn-icon">🔄</span>
|
||||
<span class="btn-text">刷新</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function log(message) {
|
||||
@ -80,14 +188,20 @@
|
||||
function init() {
|
||||
log('初始化开始');
|
||||
|
||||
const config = getConfig();
|
||||
const configData = getConfig();
|
||||
|
||||
if (!config.accessToken || !config.playUrl) {
|
||||
if (!configData.accessToken || !configData.playUrl) {
|
||||
log('配置参数不完整');
|
||||
document.getElementById('loading').textContent = '配置参数错误';
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存配置到全局变量
|
||||
config = {
|
||||
accessToken: configData.accessToken,
|
||||
playUrl: configData.playUrl
|
||||
};
|
||||
|
||||
log('AccessToken: ' + config.accessToken.substring(0, 20) + '...');
|
||||
log('PlayUrl: ' + config.playUrl);
|
||||
|
||||
@ -107,10 +221,16 @@
|
||||
const iframe = document.getElementById('player-iframe');
|
||||
iframe.src = iframeUrl;
|
||||
|
||||
// 隐藏loading
|
||||
// 设置初始播放状态
|
||||
isPlaying = true;
|
||||
document.getElementById('play-text').textContent = '暂停';
|
||||
document.getElementById('play-icon').textContent = '⏸️';
|
||||
|
||||
// 隐藏loading,显示控制按钮
|
||||
setTimeout(() => {
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
log('播放器加载完成');
|
||||
document.getElementById('control-buttons').style.display = 'flex';
|
||||
log('播放器加载完成,显示控制按钮');
|
||||
}, 2000);
|
||||
|
||||
} catch (error) {
|
||||
@ -119,11 +239,132 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 全局状态
|
||||
let isPlaying = true;
|
||||
let config = null;
|
||||
|
||||
// 播放/暂停控制
|
||||
function togglePlay() {
|
||||
log('切换播放状态: ' + (isPlaying ? '暂停' : '播放'));
|
||||
|
||||
const iframe = document.getElementById('player-iframe');
|
||||
const playText = document.getElementById('play-text');
|
||||
const playIcon = document.getElementById('play-icon');
|
||||
const pausePlaceholder = document.getElementById('pause-placeholder');
|
||||
|
||||
if (isPlaying) {
|
||||
// 暂停:清空iframe,显示占位符
|
||||
iframe.src = 'about:blank';
|
||||
pausePlaceholder.style.display = 'flex';
|
||||
playText.textContent = '播放';
|
||||
playIcon.textContent = '▶️';
|
||||
isPlaying = false;
|
||||
log('已暂停播放,显示占位符');
|
||||
} else {
|
||||
// 播放:重新设置iframe URL,隐藏占位符
|
||||
if (config) {
|
||||
const iframeUrl = 'https://open.ys7.com/ezopen/h5/iframe?' +
|
||||
'url=' + encodeURIComponent(config.playUrl) +
|
||||
'&accessToken=' + encodeURIComponent(config.accessToken) +
|
||||
'&width=100%' +
|
||||
'&height=100%' +
|
||||
'&autoplay=1' +
|
||||
'&audio=1' +
|
||||
'&controls=1';
|
||||
|
||||
iframe.src = iframeUrl;
|
||||
pausePlaceholder.style.display = 'none';
|
||||
playText.textContent = '暂停';
|
||||
playIcon.textContent = '⏸️';
|
||||
isPlaying = true;
|
||||
log('已开始播放,隐藏占位符');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新播放器
|
||||
function refreshPlayer() {
|
||||
log('刷新播放器');
|
||||
|
||||
const iframe = document.getElementById('player-iframe');
|
||||
const playText = document.getElementById('play-text');
|
||||
const playIcon = document.getElementById('play-icon');
|
||||
const pausePlaceholder = document.getElementById('pause-placeholder');
|
||||
|
||||
// 先清空,显示加载状态
|
||||
iframe.src = 'about:blank';
|
||||
pausePlaceholder.style.display = 'none';
|
||||
|
||||
// 延迟重新加载
|
||||
setTimeout(() => {
|
||||
if (config) {
|
||||
const iframeUrl = 'https://open.ys7.com/ezopen/h5/iframe?' +
|
||||
'url=' + encodeURIComponent(config.playUrl) +
|
||||
'&accessToken=' + encodeURIComponent(config.accessToken) +
|
||||
'&width=100%' +
|
||||
'&height=100%' +
|
||||
'&autoplay=1' +
|
||||
'&audio=1' +
|
||||
'&controls=1';
|
||||
|
||||
iframe.src = iframeUrl;
|
||||
playText.textContent = '暂停';
|
||||
playIcon.textContent = '⏸️';
|
||||
isPlaying = true;
|
||||
log('刷新完成');
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
// 页面加载完成后初始化
|
||||
window.onload = function() {
|
||||
log('页面加载完成');
|
||||
|
||||
// 绑定按钮事件
|
||||
document.getElementById('play-btn').addEventListener('click', togglePlay);
|
||||
document.getElementById('refresh-btn').addEventListener('click', refreshPlayer);
|
||||
|
||||
init();
|
||||
};
|
||||
|
||||
// 页面卸载时清理资源
|
||||
window.onbeforeunload = function() {
|
||||
log('页面即将卸载,清理播放器资源');
|
||||
try {
|
||||
const iframe = document.getElementById('player-iframe');
|
||||
if (iframe) {
|
||||
iframe.src = 'about:blank'; // 清空iframe源
|
||||
log('播放器资源已清理');
|
||||
}
|
||||
} catch (error) {
|
||||
log('清理播放器资源失败: ' + error.message);
|
||||
}
|
||||
};
|
||||
|
||||
// 页面隐藏时暂停播放
|
||||
document.addEventListener('visibilitychange', function() {
|
||||
if (document.hidden) {
|
||||
log('页面隐藏,暂停播放');
|
||||
try {
|
||||
const iframe = document.getElementById('player-iframe');
|
||||
if (iframe) {
|
||||
iframe.style.display = 'none';
|
||||
}
|
||||
} catch (error) {
|
||||
log('暂停播放失败: ' + error.message);
|
||||
}
|
||||
} else {
|
||||
log('页面显示,恢复播放');
|
||||
try {
|
||||
const iframe = document.getElementById('player-iframe');
|
||||
if (iframe) {
|
||||
iframe.style.display = 'block';
|
||||
}
|
||||
} catch (error) {
|
||||
log('恢复播放失败: ' + error.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user