-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
176 lines (163 loc) · 5.54 KB
/
index.html
File metadata and controls
176 lines (163 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pro Local Video Player</title>
<link href="https://vjs.zencdn.net/8.10.0/video-js.css" rel="stylesheet" />
<meta name="theme-color" content="#0f172a" />
<style>
* { box-sizing: border-box; }
body {
margin: 0;
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg,#0f172a,#1e293b);
color: white;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}
header {
padding: 20px;
font-size: 24px;
font-weight: bold;
letter-spacing: 1px;
}
.upload-area {
border: 2px dashed #38bdf8;
padding: 40px;
margin: 20px;
text-align: center;
border-radius: 15px;
cursor: pointer;
transition: 0.3s;
width: 90%;
max-width: 800px;
backdrop-filter: blur(10px);
}
.upload-area:hover {
background: rgba(56, 189, 248, 0.15);
transform: scale(1.02);
}
.player-container {
width: 95%;
max-width: 1000px;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 0 30px rgba(0,0,0,0.6);
}
.controls-extra {
margin: 15px;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
}
button, select, input {
padding: 8px 12px;
border-radius: 8px;
border: none;
font-size: 14px;
}
button {
background: #38bdf8;
color: black;
cursor: pointer;
transition: 0.2s;
}
button:hover { transform: scale(1.05); }
.theater { max-width: 100%; }
</style>
</head>
<body>
<header>🎬 Pro Local Video Player</header>
<div class="upload-area" id="dropZone">
Drag & Drop Video Here or Click to Upload
<input type="file" id="videoInput" accept="video/*" hidden />
</div>
<div class="player-container" id="playerContainer">
<video id="myVideo" class="video-js vjs-default-skin" controls preload="auto"></video>
</div>
<div class="controls-extra">
<button onclick="changeSpeed(0.5)">0.5x</button>
<button onclick="changeSpeed(1)">1x</button>
<button onclick="changeSpeed(1.5)">1.5x</button>
<button onclick="changeSpeed(2)">2x</button>
<button onclick="skip(-10)">⏪ 10s</button>
<button onclick="skip(10)">10s ⏩</button>
<button onclick="toggleTheater()">🎥 Theater</button>
<button onclick="togglePiP()">📺 PiP</button>
<button onclick="takeScreenshot()">📸 Screenshot</button>
<input type="file" id="subtitleInput" accept=".vtt,.srt" />
</div>
<script src="https://vjs.zencdn.net/8.10.0/video.min.js"></script>
<script>
const videoElement = document.getElementById("myVideo");
const videoInput = document.getElementById("videoInput");
const dropZone = document.getElementById("dropZone");
const subtitleInput = document.getElementById("subtitleInput");
const container = document.getElementById("playerContainer");
const player = videojs(videoElement);
dropZone.addEventListener("click", () => videoInput.click());
dropZone.addEventListener("dragover", e => { e.preventDefault(); dropZone.style.background="rgba(56,189,248,0.25)"; });
dropZone.addEventListener("dragleave", ()=> dropZone.style.background="");
dropZone.addEventListener("drop", e => {
e.preventDefault();
loadVideo(e.dataTransfer.files[0]);
});
videoInput.addEventListener("change", e => loadVideo(e.target.files[0]));
function loadVideo(file){
if(!file) return;
const url = URL.createObjectURL(file);
player.src({type:file.type,src:url});
player.play();
const saved = localStorage.getItem(file.name);
if(saved) player.currentTime(saved);
player.on("timeupdate", ()=> localStorage.setItem(file.name,player.currentTime()));
}
function changeSpeed(speed){ player.playbackRate(speed); }
function skip(sec){ player.currentTime(player.currentTime()+sec); }
function toggleTheater(){ container.classList.toggle("theater"); }
async function togglePiP(){
if(document.pictureInPictureElement){ document.exitPictureInPicture(); }
else{ await videoElement.requestPictureInPicture(); }
}
function takeScreenshot(){
const canvas=document.createElement("canvas");
canvas.width=videoElement.videoWidth;
canvas.height=videoElement.videoHeight;
canvas.getContext("2d").drawImage(videoElement,0,0);
const link=document.createElement("a");
link.download="screenshot.png";
link.href=canvas.toDataURL();
link.click();
}
function parseSRT(data){
return data.replace(/(\d+)\n(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})/g,
(match,p1,start,end)=>{
return `${p1}\n${start.replace(',','.') } --> ${end.replace(',','.')}`;
});
}
subtitleInput.addEventListener("change",function(){
const file=this.files[0];
if(!file) return;
const reader=new FileReader();
reader.onload=function(){
let text=reader.result;
if(file.name.endsWith('.srt')) text=parseSRT(text);
const blob=new Blob([text],{type:'text/vtt'});
const url=URL.createObjectURL(blob);
player.addRemoteTextTrack({kind:'subtitles',src:url,srclang:'en',label:'Subtitles',default:true},false);
};
reader.readAsText(file);
});
document.addEventListener("keydown",e=>{
if(e.code==="Space"){ e.preventDefault(); player.paused()?player.play():player.pause(); }
if(e.code==="ArrowRight") skip(10);
if(e.code==="ArrowLeft") skip(-10);
if(e.code==="KeyF") player.requestFullscreen();
});
</script>
</body>
</html>