Spaces:
Running
Running
Update index.html
Browse files- index.html +119 -4
index.html
CHANGED
|
@@ -394,12 +394,18 @@
|
|
| 394 |
<button class="back-button" onclick="showVideoList()">← Back to Videos</button>
|
| 395 |
|
| 396 |
<div class="video-player-section">
|
| 397 |
-
<video id="videoPlayer" class="video-player" controls>
|
|
|
|
|
|
|
|
|
|
| 398 |
Your browser does not support the video tag.
|
|
|
|
|
|
|
| 399 |
</video>
|
| 400 |
|
| 401 |
<div class="video-details">
|
| 402 |
<h2 id="currentVideoTitle">Video Title</h2>
|
|
|
|
| 403 |
</div>
|
| 404 |
</div>
|
| 405 |
|
|
@@ -657,9 +663,62 @@
|
|
| 657 |
document.getElementById('videoListContainer').style.display = 'none';
|
| 658 |
document.getElementById('videoPlayerContainer').classList.add('active');
|
| 659 |
|
| 660 |
-
// Set up video player
|
| 661 |
const videoPlayer = document.getElementById('videoPlayer');
|
| 662 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
|
| 664 |
// Update video title
|
| 665 |
document.getElementById('currentVideoTitle').textContent = video.title;
|
|
@@ -669,6 +728,18 @@
|
|
| 669 |
|
| 670 |
// Scroll to top
|
| 671 |
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 672 |
}
|
| 673 |
|
| 674 |
// Generate recommendations
|
|
@@ -719,12 +790,56 @@
|
|
| 719 |
// Handle video errors
|
| 720 |
function handleVideoError(event) {
|
| 721 |
console.error('Video error:', event);
|
| 722 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
}
|
| 724 |
|
| 725 |
// Handle video loaded
|
| 726 |
function handleVideoLoaded(event) {
|
| 727 |
console.log('Video loaded successfully');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 728 |
}
|
| 729 |
|
| 730 |
// Utility function to escape HTML
|
|
|
|
| 394 |
<button class="back-button" onclick="showVideoList()">← Back to Videos</button>
|
| 395 |
|
| 396 |
<div class="video-player-section">
|
| 397 |
+
<video id="videoPlayer" class="video-player" controls preload="metadata">
|
| 398 |
+
<source id="videoSource" type="video/mp4">
|
| 399 |
+
<source id="videoSourceWebm" type="video/webm">
|
| 400 |
+
<source id="videoSourceOgg" type="video/ogg">
|
| 401 |
Your browser does not support the video tag.
|
| 402 |
+
<p>If you're seeing this message, your browser doesn't support HTML5 video.</p>
|
| 403 |
+
<p>Try downloading the video file directly or use a different browser.</p>
|
| 404 |
</video>
|
| 405 |
|
| 406 |
<div class="video-details">
|
| 407 |
<h2 id="currentVideoTitle">Video Title</h2>
|
| 408 |
+
<div id="videoInfo" style="color: #aaa; font-size: 0.9rem; margin-top: 0.5rem;"></div>
|
| 409 |
</div>
|
| 410 |
</div>
|
| 411 |
|
|
|
|
| 663 |
document.getElementById('videoListContainer').style.display = 'none';
|
| 664 |
document.getElementById('videoPlayerContainer').classList.add('active');
|
| 665 |
|
| 666 |
+
// Set up video player with multiple source formats
|
| 667 |
const videoPlayer = document.getElementById('videoPlayer');
|
| 668 |
+
const videoSource = document.getElementById('videoSource');
|
| 669 |
+
const videoSourceWebm = document.getElementById('videoSourceWebm');
|
| 670 |
+
const videoSourceOgg = document.getElementById('videoSourceOgg');
|
| 671 |
+
|
| 672 |
+
// Clear previous sources
|
| 673 |
+
videoPlayer.removeAttribute('src');
|
| 674 |
+
videoSource.removeAttribute('src');
|
| 675 |
+
videoSourceWebm.removeAttribute('src');
|
| 676 |
+
videoSourceOgg.removeAttribute('src');
|
| 677 |
+
|
| 678 |
+
// Set video info
|
| 679 |
+
const videoInfo = document.getElementById('videoInfo');
|
| 680 |
+
videoInfo.innerHTML = `
|
| 681 |
+
<p>Original URL: <a href="${video.url}" target="_blank" style="color: #ff6b6b;">${video.url}</a></p>
|
| 682 |
+
<p>Format: ${getFileExtension(video.url).toUpperCase()}</p>
|
| 683 |
+
`;
|
| 684 |
+
|
| 685 |
+
// Detect file format and set appropriate source
|
| 686 |
+
const extension = getFileExtension(video.url).toLowerCase();
|
| 687 |
+
|
| 688 |
+
if (extension === 'mkv') {
|
| 689 |
+
// MKV files might not work in browsers - show warning
|
| 690 |
+
videoInfo.innerHTML += `
|
| 691 |
+
<div style="background: #ff6600; color: white; padding: 0.5rem; border-radius: 4px; margin-top: 0.5rem;">
|
| 692 |
+
<strong>⚠️ MKV Format Warning:</strong> MKV files may not play in web browsers.
|
| 693 |
+
Consider converting to MP4 format for better compatibility.
|
| 694 |
+
</div>
|
| 695 |
+
`;
|
| 696 |
+
// Try anyway
|
| 697 |
+
videoSource.src = video.url;
|
| 698 |
+
videoSource.type = 'video/mp4'; // Sometimes MKV works with mp4 mime type
|
| 699 |
+
} else if (extension === 'mp4') {
|
| 700 |
+
videoSource.src = video.url;
|
| 701 |
+
videoSource.type = 'video/mp4';
|
| 702 |
+
} else if (extension === 'webm') {
|
| 703 |
+
videoSourceWebm.src = video.url;
|
| 704 |
+
videoSourceWebm.type = 'video/webm';
|
| 705 |
+
} else if (extension === 'ogg' || extension === 'ogv') {
|
| 706 |
+
videoSourceOgg.src = video.url;
|
| 707 |
+
videoSourceOgg.type = 'video/ogg';
|
| 708 |
+
} else {
|
| 709 |
+
// Unknown format - try as mp4
|
| 710 |
+
videoSource.src = video.url;
|
| 711 |
+
videoSource.type = 'video/mp4';
|
| 712 |
+
videoInfo.innerHTML += `
|
| 713 |
+
<div style="background: #ff6600; color: white; padding: 0.5rem; border-radius: 4px; margin-top: 0.5rem;">
|
| 714 |
+
<strong>⚠️ Unknown Format:</strong> Attempting to play as MP4.
|
| 715 |
+
If playback fails, please convert to a web-compatible format.
|
| 716 |
+
</div>
|
| 717 |
+
`;
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
// Force reload the video element
|
| 721 |
+
videoPlayer.load();
|
| 722 |
|
| 723 |
// Update video title
|
| 724 |
document.getElementById('currentVideoTitle').textContent = video.title;
|
|
|
|
| 728 |
|
| 729 |
// Scroll to top
|
| 730 |
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 731 |
+
|
| 732 |
+
// Add video event listeners for debugging
|
| 733 |
+
videoPlayer.addEventListener('loadstart', () => console.log('Video load started'));
|
| 734 |
+
videoPlayer.addEventListener('loadeddata', () => console.log('Video data loaded'));
|
| 735 |
+
videoPlayer.addEventListener('canplay', () => console.log('Video can start playing'));
|
| 736 |
+
videoPlayer.addEventListener('canplaythrough', () => console.log('Video can play through'));
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
// Get file extension from URL
|
| 740 |
+
function getFileExtension(url) {
|
| 741 |
+
const pathname = new URL(url).pathname;
|
| 742 |
+
return pathname.split('.').pop() || '';
|
| 743 |
}
|
| 744 |
|
| 745 |
// Generate recommendations
|
|
|
|
| 790 |
// Handle video errors
|
| 791 |
function handleVideoError(event) {
|
| 792 |
console.error('Video error:', event);
|
| 793 |
+
const videoPlayer = document.getElementById('videoPlayer');
|
| 794 |
+
console.error('Video error details:', {
|
| 795 |
+
error: videoPlayer.error,
|
| 796 |
+
networkState: videoPlayer.networkState,
|
| 797 |
+
readyState: videoPlayer.readyState,
|
| 798 |
+
src: videoPlayer.src
|
| 799 |
+
});
|
| 800 |
+
|
| 801 |
+
// Show detailed error message
|
| 802 |
+
const errorDiv = document.createElement('div');
|
| 803 |
+
errorDiv.style.cssText = `
|
| 804 |
+
background: #ff4444;
|
| 805 |
+
color: white;
|
| 806 |
+
padding: 1rem;
|
| 807 |
+
border-radius: 8px;
|
| 808 |
+
margin: 1rem 0;
|
| 809 |
+
text-align: center;
|
| 810 |
+
`;
|
| 811 |
+
errorDiv.innerHTML = `
|
| 812 |
+
<h3>Video Loading Error</h3>
|
| 813 |
+
<p>The video format may not be supported by your browser.</p>
|
| 814 |
+
<p><strong>Suggested solutions:</strong></p>
|
| 815 |
+
<ul style="text-align: left; margin: 0.5rem 0;">
|
| 816 |
+
<li>Try converting MKV files to MP4 format</li>
|
| 817 |
+
<li>Ensure video codecs are web-compatible (H.264/H.265)</li>
|
| 818 |
+
<li>Check if the video URL is accessible</li>
|
| 819 |
+
<li>Try opening the video URL directly in browser</li>
|
| 820 |
+
</ul>
|
| 821 |
+
<p style="font-size: 0.9rem; margin-top: 1rem;">
|
| 822 |
+
Video URL: <a href="${videoPlayer.src}" target="_blank" style="color: #ffff99;">${videoPlayer.src}</a>
|
| 823 |
+
</p>
|
| 824 |
+
`;
|
| 825 |
+
|
| 826 |
+
videoPlayer.parentNode.insertBefore(errorDiv, videoPlayer.nextSibling);
|
| 827 |
}
|
| 828 |
|
| 829 |
// Handle video loaded
|
| 830 |
function handleVideoLoaded(event) {
|
| 831 |
console.log('Video loaded successfully');
|
| 832 |
+
const videoPlayer = document.getElementById('videoPlayer');
|
| 833 |
+
console.log('Video metadata:', {
|
| 834 |
+
duration: videoPlayer.duration,
|
| 835 |
+
videoWidth: videoPlayer.videoWidth,
|
| 836 |
+
videoHeight: videoPlayer.videoHeight,
|
| 837 |
+
readyState: videoPlayer.readyState
|
| 838 |
+
});
|
| 839 |
+
|
| 840 |
+
// Remove any previous error messages
|
| 841 |
+
const errorDivs = document.querySelectorAll('.video-player-section > div[style*="background: #ff4444"]');
|
| 842 |
+
errorDivs.forEach(div => div.remove());
|
| 843 |
}
|
| 844 |
|
| 845 |
// Utility function to escape HTML
|