582 lines
18 KiB
PHP
582 lines
18 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Media Player</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Archivo:wght@300;400;600&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--bg-primary: #0a0e14;
|
|
--bg-secondary: #151b24;
|
|
--bg-tertiary: #1f2937;
|
|
--accent-primary: #00ffcc;
|
|
--accent-secondary: #ff00ff;
|
|
--text-primary: #e8edf3;
|
|
--text-secondary: #8b95a8;
|
|
--border-color: #2d3748;
|
|
--shadow-glow: 0 0 20px rgba(0, 255, 204, 0.3);
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Archivo', sans-serif;
|
|
background: linear-gradient(135deg, var(--bg-primary) 0%, #0d1117 50%, var(--bg-secondary) 100%);
|
|
color: var(--text-primary);
|
|
min-height: 100vh;
|
|
overflow-x: hidden;
|
|
}
|
|
|
|
body::before {
|
|
content: '';
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background:
|
|
radial-gradient(circle at 20% 50%, rgba(0, 255, 204, 0.05) 0%, transparent 50%),
|
|
radial-gradient(circle at 80% 20%, rgba(255, 0, 255, 0.05) 0%, transparent 50%);
|
|
pointer-events: none;
|
|
z-index: 0;
|
|
}
|
|
|
|
.container {
|
|
position: relative;
|
|
max-width: 1600px;
|
|
margin: 0 auto;
|
|
padding: 2rem;
|
|
z-index: 1;
|
|
}
|
|
|
|
header {
|
|
text-align: center;
|
|
margin-bottom: 3rem;
|
|
animation: slideDown 0.8s ease-out;
|
|
}
|
|
|
|
@keyframes slideDown {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(-30px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
h1 {
|
|
font-family: 'Orbitron', sans-serif;
|
|
font-size: 3.5rem;
|
|
font-weight: 900;
|
|
background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
letter-spacing: 0.05em;
|
|
text-transform: uppercase;
|
|
margin-bottom: 0.5rem;
|
|
filter: drop-shadow(0 0 30px rgba(0, 255, 204, 0.5));
|
|
}
|
|
|
|
.subtitle {
|
|
color: var(--text-secondary);
|
|
font-size: 0.9rem;
|
|
letter-spacing: 0.2em;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.main-layout {
|
|
display: grid;
|
|
grid-template-columns: 350px 1fr;
|
|
gap: 2rem;
|
|
animation: fadeIn 1s ease-out 0.3s both;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
.sidebar {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 12px;
|
|
padding: 1.5rem;
|
|
height: fit-content;
|
|
position: sticky;
|
|
top: 2rem;
|
|
backdrop-filter: blur(10px);
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
.media-type-tabs {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.tab-btn {
|
|
flex: 1;
|
|
padding: 0.75rem;
|
|
background: var(--bg-tertiary);
|
|
border: 1px solid var(--border-color);
|
|
color: var(--text-secondary);
|
|
font-family: 'Orbitron', sans-serif;
|
|
font-size: 0.85rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
cursor: pointer;
|
|
border-radius: 6px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.tab-btn:hover {
|
|
background: var(--bg-primary);
|
|
border-color: var(--accent-primary);
|
|
color: var(--accent-primary);
|
|
}
|
|
|
|
.tab-btn.active {
|
|
background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
|
|
border-color: var(--accent-primary);
|
|
color: var(--bg-primary);
|
|
font-weight: 700;
|
|
box-shadow: var(--shadow-glow);
|
|
}
|
|
|
|
.file-browser {
|
|
max-height: 600px;
|
|
overflow-y: auto;
|
|
padding-right: 0.5rem;
|
|
}
|
|
|
|
.file-browser::-webkit-scrollbar {
|
|
width: 6px;
|
|
}
|
|
|
|
.file-browser::-webkit-scrollbar-track {
|
|
background: var(--bg-tertiary);
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.file-browser::-webkit-scrollbar-thumb {
|
|
background: var(--accent-primary);
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.folder {
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.folder-header {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0.6rem 0.8rem;
|
|
background: var(--bg-tertiary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.folder-header:hover {
|
|
background: var(--bg-primary);
|
|
border-color: var(--accent-primary);
|
|
transform: translateX(3px);
|
|
}
|
|
|
|
.folder-icon {
|
|
margin-right: 0.5rem;
|
|
font-size: 1.1rem;
|
|
transition: transform 0.2s ease;
|
|
}
|
|
|
|
.folder.open .folder-icon {
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
.folder-content {
|
|
display: none;
|
|
padding-left: 1.5rem;
|
|
margin-top: 0.5rem;
|
|
}
|
|
|
|
.folder.open .folder-content {
|
|
display: block;
|
|
}
|
|
|
|
.file-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0.6rem 0.8rem;
|
|
margin-bottom: 0.3rem;
|
|
background: var(--bg-primary);
|
|
border: 1px solid transparent;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
font-size: 0.85rem;
|
|
}
|
|
|
|
.file-item:hover {
|
|
border-color: var(--accent-primary);
|
|
background: var(--bg-tertiary);
|
|
transform: translateX(5px);
|
|
box-shadow: -3px 0 0 0 var(--accent-primary);
|
|
}
|
|
|
|
.file-item.active {
|
|
background: linear-gradient(90deg, rgba(0, 255, 204, 0.15) 0%, transparent 100%);
|
|
border-color: var(--accent-primary);
|
|
color: var(--accent-primary);
|
|
box-shadow: -3px 0 0 0 var(--accent-primary);
|
|
}
|
|
|
|
.file-icon {
|
|
margin-right: 0.5rem;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.player-section {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 12px;
|
|
padding: 2rem;
|
|
backdrop-filter: blur(10px);
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
.player-container {
|
|
background: var(--bg-primary);
|
|
border: 2px solid var(--border-color);
|
|
border-radius: 12px;
|
|
padding: 2rem;
|
|
min-height: 400px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.player-container::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: -50%;
|
|
left: -50%;
|
|
width: 200%;
|
|
height: 200%;
|
|
background: radial-gradient(circle, rgba(0, 255, 204, 0.03) 0%, transparent 70%);
|
|
animation: pulse 4s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0%, 100% {
|
|
transform: scale(1);
|
|
opacity: 1;
|
|
}
|
|
50% {
|
|
transform: scale(1.1);
|
|
opacity: 0.8;
|
|
}
|
|
}
|
|
|
|
.player-placeholder {
|
|
text-align: center;
|
|
color: var(--text-secondary);
|
|
z-index: 1;
|
|
}
|
|
|
|
.player-placeholder-icon {
|
|
font-size: 4rem;
|
|
margin-bottom: 1rem;
|
|
opacity: 0.3;
|
|
}
|
|
|
|
video, audio {
|
|
max-width: 100%;
|
|
max-height: 500px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
|
|
z-index: 1;
|
|
}
|
|
|
|
audio {
|
|
width: 100%;
|
|
}
|
|
|
|
.now-playing {
|
|
margin-top: 1.5rem;
|
|
padding: 1.5rem;
|
|
background: var(--bg-tertiary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
}
|
|
|
|
.now-playing-label {
|
|
font-size: 0.75rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.1em;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.now-playing-title {
|
|
font-family: 'Orbitron', sans-serif;
|
|
font-size: 1.3rem;
|
|
color: var(--accent-primary);
|
|
font-weight: 600;
|
|
}
|
|
|
|
.loading {
|
|
display: inline-block;
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 3px solid var(--border-color);
|
|
border-top-color: var(--accent-primary);
|
|
border-radius: 50%;
|
|
animation: spin 0.8s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
|
|
@media (max-width: 1024px) {
|
|
.main-layout {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.sidebar {
|
|
position: static;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 2.5rem;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1>Media Player</h1>
|
|
<div class="subtitle">Your Digital Entertainment Hub</div>
|
|
</header>
|
|
|
|
<div class="main-layout">
|
|
<aside class="sidebar">
|
|
<div class="media-type-tabs">
|
|
<button class="tab-btn active" data-type="videos">Videos</button>
|
|
<button class="tab-btn" data-type="music">Music</button>
|
|
</div>
|
|
<div class="file-browser" id="fileBrowser">
|
|
<div class="loading"></div>
|
|
</div>
|
|
</aside>
|
|
|
|
<main class="player-section">
|
|
<div class="player-container" id="playerContainer">
|
|
<div class="player-placeholder">
|
|
<div class="player-placeholder-icon">🎵</div>
|
|
<p>Select a file to start playing</p>
|
|
</div>
|
|
</div>
|
|
<div class="now-playing" id="nowPlaying" style="display: none;">
|
|
<div class="now-playing-label">Now Playing</div>
|
|
<div class="now-playing-title" id="nowPlayingTitle"></div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const state = {
|
|
currentType: 'videos',
|
|
currentFile: null,
|
|
filesData: null
|
|
};
|
|
|
|
// Initialize
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
loadFiles('videos');
|
|
setupTabListeners();
|
|
});
|
|
|
|
function setupTabListeners() {
|
|
document.querySelectorAll('.tab-btn').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
const type = btn.dataset.type;
|
|
document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
|
|
btn.classList.add('active');
|
|
state.currentType = type;
|
|
loadFiles(type);
|
|
});
|
|
});
|
|
}
|
|
|
|
async function loadFiles(type) {
|
|
const browser = document.getElementById('fileBrowser');
|
|
browser.innerHTML = '<div class="loading"></div>';
|
|
|
|
try {
|
|
const response = await fetch(`get_files.php?type=${type}`);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
|
|
const contentType = response.headers.get('content-type');
|
|
if (!contentType || !contentType.includes('application/json')) {
|
|
const text = await response.text();
|
|
console.error('Non-JSON response:', text);
|
|
throw new Error('Server returned non-JSON response');
|
|
}
|
|
|
|
const data = await response.json();
|
|
console.log('Loaded files:', data);
|
|
|
|
if (data.error) {
|
|
browser.innerHTML = `<p style="color: #ff6b6b; padding: 1rem;">${data.error}</p>`;
|
|
return;
|
|
}
|
|
|
|
if (data.message) {
|
|
browser.innerHTML = `<p style="color: var(--text-secondary); padding: 1rem;">${data.message}</p>`;
|
|
return;
|
|
}
|
|
|
|
state.filesData = data;
|
|
renderFileTree(data);
|
|
} catch (error) {
|
|
console.error('Error loading files:', error);
|
|
browser.innerHTML = `<p style="color: #ff6b6b; padding: 1rem;">Error loading files: ${error.message}</p>`;
|
|
}
|
|
}
|
|
|
|
function renderFileTree(files, container = document.getElementById('fileBrowser'), depth = 0) {
|
|
if (depth === 0) {
|
|
container.innerHTML = '';
|
|
}
|
|
|
|
for (const [name, content] of Object.entries(files)) {
|
|
if (typeof content === 'object' && !Array.isArray(content)) {
|
|
// It's a folder
|
|
const folder = document.createElement('div');
|
|
folder.className = 'folder';
|
|
|
|
const header = document.createElement('div');
|
|
header.className = 'folder-header';
|
|
header.innerHTML = `<span class="folder-icon">▶</span><span>${name}</span>`;
|
|
|
|
const folderContent = document.createElement('div');
|
|
folderContent.className = 'folder-content';
|
|
|
|
header.addEventListener('click', () => {
|
|
folder.classList.toggle('open');
|
|
});
|
|
|
|
folder.appendChild(header);
|
|
folder.appendChild(folderContent);
|
|
container.appendChild(folder);
|
|
|
|
renderFileTree(content, folderContent, depth + 1);
|
|
} else if (typeof content === 'string') {
|
|
// It's a file
|
|
const fileItem = document.createElement('div');
|
|
fileItem.className = 'file-item';
|
|
|
|
const icon = state.currentType === 'videos' ? '🎬' : '🎵';
|
|
fileItem.innerHTML = `<span class="file-icon">${icon}</span><span>${name}</span>`;
|
|
|
|
fileItem.addEventListener('click', () => {
|
|
playFile(content, name);
|
|
document.querySelectorAll('.file-item').forEach(f => f.classList.remove('active'));
|
|
fileItem.classList.add('active');
|
|
});
|
|
|
|
container.appendChild(fileItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
function playFile(path, name) {
|
|
const playerContainer = document.getElementById('playerContainer');
|
|
const nowPlaying = document.getElementById('nowPlaying');
|
|
const nowPlayingTitle = document.getElementById('nowPlayingTitle');
|
|
|
|
state.currentFile = { path, name };
|
|
|
|
const isVideo = state.currentType === 'videos';
|
|
const mediaElement = document.createElement(isVideo ? 'video' : 'audio');
|
|
|
|
mediaElement.controls = true;
|
|
mediaElement.autoplay = true;
|
|
|
|
// Add error handling
|
|
mediaElement.addEventListener('error', (e) => {
|
|
console.error('Media playback error:', {
|
|
error: mediaElement.error,
|
|
code: mediaElement.error?.code,
|
|
message: mediaElement.error?.message,
|
|
path: path,
|
|
name: name
|
|
});
|
|
|
|
playerContainer.innerHTML = `
|
|
<div class="player-placeholder">
|
|
<div class="player-placeholder-icon">⚠️</div>
|
|
<p style="color: #ff6b6b;">Error playing: ${name}</p>
|
|
<p style="color: var(--text-secondary); font-size: 0.8rem; margin-top: 0.5rem;">
|
|
${mediaElement.error?.message || 'Unknown error'}
|
|
</p>
|
|
</div>
|
|
`;
|
|
});
|
|
|
|
// Add loading state
|
|
mediaElement.addEventListener('loadstart', () => {
|
|
console.log('Loading media:', name);
|
|
});
|
|
|
|
mediaElement.addEventListener('canplay', () => {
|
|
console.log('Media ready to play:', name);
|
|
});
|
|
|
|
// URL encode the path properly
|
|
const encodedPath = encodeURIComponent(path);
|
|
mediaElement.src = `serve_media.php?file=${encodedPath}`;
|
|
|
|
console.log('Playing file:', {
|
|
name: name,
|
|
path: path,
|
|
encodedPath: encodedPath,
|
|
fullUrl: `serve_media.php?file=${encodedPath}`
|
|
});
|
|
|
|
playerContainer.innerHTML = '';
|
|
playerContainer.appendChild(mediaElement);
|
|
|
|
nowPlayingTitle.textContent = name;
|
|
nowPlaying.style.display = 'block';
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|