|
@@ -0,0 +1,311 @@
|
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
|
+<html lang="zh-CN">
|
|
|
|
|
+<head>
|
|
|
|
|
+ <meta charset="UTF-8">
|
|
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
+ <title>MES大屏轮播播放器</title>
|
|
|
|
|
+ <style>
|
|
|
|
|
+ * {
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+ padding: 0;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
|
+ }
|
|
|
|
|
+ html, body {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ background: #000;
|
|
|
|
|
+ }
|
|
|
|
|
+ #player-container {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ }
|
|
|
|
|
+ #player-frame {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ display: block;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ }
|
|
|
|
|
+ #control-bar {
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ top: 0;
|
|
|
|
|
+ right: 0;
|
|
|
|
|
+ height: 30px;
|
|
|
|
|
+ background: rgba(0, 0, 0, 0.6);
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding: 0 15px;
|
|
|
|
|
+ z-index: 1000;
|
|
|
|
|
+ opacity: 0;
|
|
|
|
|
+ transition: opacity 0.3s;
|
|
|
|
|
+ }
|
|
|
|
|
+ #control-bar:hover {
|
|
|
|
|
+ opacity: 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ #fullscreen-btn {
|
|
|
|
|
+ background: none;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ padding: 5px 10px;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ }
|
|
|
|
|
+ #fullscreen-btn:hover {
|
|
|
|
|
+ color: #1890ff;
|
|
|
|
|
+ }
|
|
|
|
|
+ #screen-info {
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ }
|
|
|
|
|
+ #screen-info span {
|
|
|
|
|
+ margin-right: 15px;
|
|
|
|
|
+ }
|
|
|
|
|
+ #progress-bar {
|
|
|
|
|
+ width: 100px;
|
|
|
|
|
+ height: 3px;
|
|
|
|
|
+ background: rgba(255,255,255,0.3);
|
|
|
|
|
+ margin: 0 10px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ }
|
|
|
|
|
+ #progress-fill {
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ background: #1890ff;
|
|
|
|
|
+ width: 0;
|
|
|
|
|
+ transition: width 1s linear;
|
|
|
|
|
+ }
|
|
|
|
|
+ #time-info {
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ min-width: 40px;
|
|
|
|
|
+ text-align: right;
|
|
|
|
|
+ }
|
|
|
|
|
+ .hidden {
|
|
|
|
|
+ display: none !important;
|
|
|
|
|
+ }
|
|
|
|
|
+ #loading {
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ top: 0;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ right: 0;
|
|
|
|
|
+ bottom: 0;
|
|
|
|
|
+ background: #000;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ z-index: 2000;
|
|
|
|
|
+ }
|
|
|
|
|
+ #loading .spinner {
|
|
|
|
|
+ width: 50px;
|
|
|
|
|
+ height: 50px;
|
|
|
|
|
+ border: 4px solid #333;
|
|
|
|
|
+ border-top: 4px solid #1890ff;
|
|
|
|
|
+ border-radius: 50%;
|
|
|
|
|
+ animation: spin 1s linear infinite;
|
|
|
|
|
+ }
|
|
|
|
|
+ @keyframes spin {
|
|
|
|
|
+ 0% { transform: rotate(0deg); }
|
|
|
|
|
+ 100% { transform: rotate(360deg); }
|
|
|
|
|
+ }
|
|
|
|
|
+ #loading-text {
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ margin-top: 20px;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ }
|
|
|
|
|
+ #no-screen {
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ top: 0;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ right: 0;
|
|
|
|
|
+ bottom: 0;
|
|
|
|
|
+ background: #000;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ z-index: 2000;
|
|
|
|
|
+ }
|
|
|
|
|
+ #no-screen h2 {
|
|
|
|
|
+ color: #ff4d4f;
|
|
|
|
|
+ font-size: 24px;
|
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
|
+ }
|
|
|
|
|
+ #no-screen p {
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ }
|
|
|
|
|
+ </style>
|
|
|
|
|
+</head>
|
|
|
|
|
+<body>
|
|
|
|
|
+ <div id="loading">
|
|
|
|
|
+ <div style="text-align: center;">
|
|
|
|
|
+ <div class="spinner"></div>
|
|
|
|
|
+ <div id="loading-text">加载中...</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div id="no-screen" class="hidden">
|
|
|
|
|
+ <h2>暂无大屏配置</h2>
|
|
|
|
|
+ <p>请先在管理页面配置需要轮播的大屏</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div id="player-container">
|
|
|
|
|
+ <iframe id="player-frame" src=""></iframe>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div id="control-bar" class="hidden">
|
|
|
|
|
+ <div id="screen-info">
|
|
|
|
|
+ <span id="current-screen-name"></span>
|
|
|
|
|
+ <span id="screen-count"></span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div id="progress-bar">
|
|
|
|
|
+ <div id="progress-fill"></div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div id="time-info">
|
|
|
|
|
+ <span id="countdown">60</span>s
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <button id="fullscreen-btn" onclick="toggleFullScreen()">全屏</button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <script src="https://cdn.jsdelivr.net/npm/jquery@1.11.3/dist/jquery.min.js"></script>
|
|
|
|
|
+ <script>
|
|
|
|
|
+ var screens = [];
|
|
|
|
|
+ var currentIndex = 0;
|
|
|
|
|
+ var currentDuration = 60;
|
|
|
|
|
+ var countdownTimer = null;
|
|
|
|
|
+ var progressTimer = null;
|
|
|
|
|
+ var remainingTime = 0;
|
|
|
|
|
+
|
|
|
|
|
+ var ctxPath = window.location.origin + '/js/a';
|
|
|
|
|
+
|
|
|
|
|
+ $(function() {
|
|
|
|
|
+ loadScreens();
|
|
|
|
|
+ document.addEventListener('keydown', function(e) {
|
|
|
|
|
+ if (e.key === 'ArrowLeft') {
|
|
|
|
|
+ playScreen(currentIndex - 1);
|
|
|
|
|
+ } else if (e.key === 'ArrowRight') {
|
|
|
|
|
+ playScreen(currentIndex + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ function loadScreens() {
|
|
|
|
|
+ var url = ctxPath + "/mes/mesScreenConfig/getScreenList";
|
|
|
|
|
+ $.get(url, function(res) {
|
|
|
|
|
+ if (res.result === "true" && res.data && res.data.length > 0) {
|
|
|
|
|
+ screens = res.data;
|
|
|
|
|
+ $('#loading').addClass('hidden');
|
|
|
|
|
+ $('#control-bar').removeClass('hidden');
|
|
|
|
|
+ playScreen(0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $('#loading').addClass('hidden');
|
|
|
|
|
+ $('#no-screen').removeClass('hidden');
|
|
|
|
|
+ }
|
|
|
|
|
+ }).fail(function() {
|
|
|
|
|
+ $('#loading').addClass('hidden');
|
|
|
|
|
+ $('#no-screen').removeClass('hidden');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function playScreen(index) {
|
|
|
|
|
+ if (index < 0) {
|
|
|
|
|
+ index = screens.length - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (index >= screens.length) {
|
|
|
|
|
+ index = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ currentIndex = index;
|
|
|
|
|
+ var screen = screens[index];
|
|
|
|
|
+
|
|
|
|
|
+ currentDuration = screen.playDuration || 60;
|
|
|
|
|
+ remainingTime = currentDuration;
|
|
|
|
|
+
|
|
|
|
|
+ $('#current-screen-name').text(screen.screenName);
|
|
|
|
|
+ $('#screen-count').text((index + 1) + '/' + screens.length);
|
|
|
|
|
+ $('#countdown').text(remainingTime);
|
|
|
|
|
+ $('#progress-fill').css('width', '0%');
|
|
|
|
|
+
|
|
|
|
|
+ var screenUrl = screen.screenUrl;
|
|
|
|
|
+ if (screenUrl.startsWith('http')) {
|
|
|
|
|
+ // 绝对URL,直接使用
|
|
|
|
|
+ } else if (screenUrl.startsWith('/js/')) {
|
|
|
|
|
+ // 前端路由路径,已经包含 /js 前缀
|
|
|
|
|
+ screenUrl = window.location.origin + screenUrl;
|
|
|
|
|
+ } else if (!screenUrl.startsWith('/')) {
|
|
|
|
|
+ screenUrl = ctxPath + '/' + screenUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $('#player-frame').attr('src', screenUrl);
|
|
|
|
|
+
|
|
|
|
|
+ startCountdown();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function startCountdown() {
|
|
|
|
|
+ clearInterval(countdownTimer);
|
|
|
|
|
+
|
|
|
|
|
+ $('#progress-fill').css('width', '0%');
|
|
|
|
|
+ $('#progress-fill').css('transition', 'none');
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ $('#progress-fill').css('transition', 'width ' + currentDuration + 's linear');
|
|
|
|
|
+ $('#progress-fill').css('width', '100%');
|
|
|
|
|
+ }, 100);
|
|
|
|
|
+
|
|
|
|
|
+ countdownTimer = setInterval(function() {
|
|
|
|
|
+ remainingTime--;
|
|
|
|
|
+ $('#countdown').text(remainingTime);
|
|
|
|
|
+
|
|
|
|
|
+ if (remainingTime <= 0) {
|
|
|
|
|
+ clearInterval(countdownTimer);
|
|
|
|
|
+ playScreen(currentIndex + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 1000);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function changeScreen(index) {
|
|
|
|
|
+ playScreen(index);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function toggleFullScreen() {
|
|
|
|
|
+ if (!document.fullscreenElement) {
|
|
|
|
|
+ var elem = document.documentElement;
|
|
|
|
|
+ if (elem.requestFullscreen) {
|
|
|
|
|
+ elem.requestFullscreen();
|
|
|
|
|
+ } else if (elem.webkitRequestFullscreen) {
|
|
|
|
|
+ elem.webkitRequestFullscreen();
|
|
|
|
|
+ } else if (elem.msRequestFullscreen) {
|
|
|
|
|
+ elem.msRequestFullscreen();
|
|
|
|
|
+ }
|
|
|
|
|
+ document.getElementById('fullscreen-btn').textContent = '退出全屏';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (document.exitFullscreen) {
|
|
|
|
|
+ document.exitFullscreen();
|
|
|
|
|
+ } else if (document.webkitExitFullscreen) {
|
|
|
|
|
+ document.webkitExitFullscreen();
|
|
|
|
|
+ } else if (document.msExitFullscreen) {
|
|
|
|
|
+ document.msExitFullscreen();
|
|
|
|
|
+ }
|
|
|
|
|
+ document.getElementById('fullscreen-btn').textContent = '全屏';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ document.addEventListener('fullscreenchange', function() {
|
|
|
|
|
+ updateFullscreenBtn();
|
|
|
|
|
+ });
|
|
|
|
|
+ document.addEventListener('webkitfullscreenchange', function() {
|
|
|
|
|
+ updateFullscreenBtn();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ function updateFullscreenBtn() {
|
|
|
|
|
+ if (document.fullscreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
|
|
|
|
|
+ document.getElementById('fullscreen-btn').textContent = '退出全屏';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ document.getElementById('fullscreen-btn').textContent = '全屏';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ </script>
|
|
|
|
|
+</body>
|
|
|
|
|
+</html>
|