| | |
| | | height: 100%; |
| | | object-fit: fill; |
| | | } |
| | | #loadingMessage { |
| | | position: absolute; |
| | | top: 50%; |
| | | left: 50%; |
| | | transform: translate(-50%, -50%); |
| | | font-size: 24px; |
| | | color: white; |
| | | background-color: rgba(0, 0, 0, 0.7); |
| | | padding: 10px 20px; |
| | | border-radius: 5px; |
| | | display: none; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | |
| | | <div class="container" id="gridContainer"> |
| | | <!-- 网格项目将由 JavaScript 动态生成 --> |
| | | </div> |
| | | <div id="loadingMessage">正在取流</div> |
| | | <div class="container2"> |
| | | <div class="button-container"> |
| | | <button class="toggle-button" onclick="changeGrid(1, 1)">1x1</button> |
| | |
| | | video.controls = true; |
| | | video.autoplay = true; |
| | | video.muted = true; |
| | | video.loop= true; |
| | | |
| | | videoContainer.appendChild(video); |
| | | gridItem.appendChild(videoContainer); |
| | | gridContainer.appendChild(gridItem); |
| | | |
| | | video.addEventListener('loadedmetadata', function () { |
| | | adjustGridItemSize(gridItem, gridItem.videoWidth, gridItem.videoHeight); |
| | | }); |
| | | video.addEventListener("click", function() { |
| | | loadingMessage.style.display = "block"; |
| | | video.play().then(function() { |
| | | loadingMessage.style.display = "none"; |
| | | }).catch(function(error) { |
| | | console.error("Error playing the video:", error); |
| | | loadingMessage.style.display = "none"; |
| | | }); |
| | | }); |
| | | console.log(video.id) |
| | | } |
| | |
| | | client.stop(id); |
| | | videoMap.delete(id); |
| | | } |
| | | |
| | | function closeAllVideo(){ |
| | | videoMap.forEach((val,key) => { |
| | | console.log(val,key); |