Código de HTML - Reproductor vídeo HTML5

Imágen de perfil

Reproductor vídeo HTML5gráfica de visualizaciones


HTML

estrellaestrellaestrellaestrellaestrella(1)
Publicado el 25 de Marzo del 2016 por Izan
1.511 visualizaciones desde el 25 de Marzo del 2016. Una media de 42 por semana
Un reproductor al estilo youtube (no tan logrado, obviamente).

Es útil si quieres crear una web con tu propio reproductor de vídeos.

Requerimientos

Buscador con HTML5 y JavaScript habilitado.

1.0
estrellaestrellaestrellaestrellaestrella(1)

Actualizado el 28 de Marzo del 2016 (Creado el 25 de Marzo del 2016)gráfica de visualizaciones de la versión: 1.0
1.512 visualizaciones desde el 25 de Marzo del 2016. Una media de 42 por semana
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!doctype html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Player Izan</title>
    <base href="./src/">
    <style>
	html{
		background-color: rgb(150,150,150);
	}
	video::-webkit-media-controls-enclosure {
		/*display:none !important;
		z-index: 2147483647;*/
	}
	video{
		transition: -webkit-filter 0.3s ease-in-out;
	}
	#player{
		position: absolute;
		left: calc(50% - 720px/2);
		top: 10%;
		background-color: rgb(30,30,30);
		display: inline-block;
		-webkit-user-select: none;
	}
	img{
		padding: 10px;
	}
	img, #pbar-container, #sbar-container{
		transition: -webkit-filter 0.15s ease-in-out;
		cursor: pointer;
	}
	img:hover{
		-webkit-filter: invert(100%);
	}
	#video-container{
		width: 640px;
		height: 320px;
	}
	video{
		height: 100%;
		width: 100%;
	}
	#pbar-container{
		position: relative;
		margin-top: 2px;
		padding-bottom: 2px;
		background-color: rgb(70,70,70);
	}
	#pbar{
		height: 5px;
		width: 0%;
		background-color: rgb(50, 170, 220);
	}
	#buttons-container{
		width: 100%;
	}
	#buttons-container > *{
		display: inline-block;
		height: 100%;
		vertical-align: middle;
	}
	#time-field{
		color: rgb(50, 170, 220);
		line-height: 50px;
	}
	#sound-button{
		margin-right: 0;
	}
	#sbar-container{
		position: relative;
		margin-left: 0;
		width: 100px;
		height: 5px;
		background-color: rgb(70,70,70);
	}
	#sbar{
		height: 100%;
		width: 50%;
		background-color: rgb(50, 170, 220);
	}
	#fullscreen-button{
		float: right;
	}
	</style>
</head>
<body>
 
    <div id="player">
 
        <div id="video-container">
            <video id="video" poster="poster.png" width="720px">
                <source src="video.mp4" type="video/mp4">
                Tu navegador no soporta los vídeos, por favor, actualízalo.
            </video>
        </div>
 
        <div id="pbar-container">
            <div id="pbar"></div>
        </div>
 
        <div id="buttons-container">
            <img id="play-button" src="img/play_button.png" width="30" draggable="false">
            <div id="time-field">
                0:00 / 0:00
            </div>
            <img id="sound-button" src="img/sound_button.png" width="38" draggable="false">
            <div id="sbar-container">
                <div id="sbar"></div>
            </div>
            <img id="fullscreen-button" src="img/fullscreen_button.png" width="45" draggable="false">
        </div>
 
    </div>
 
    <div id="fileSelect">
        <label for="file">Put your own video</label>
        <input type="file" name="file1" id="file1"/>
        <input type="submit" value="Subir" id="sub"/>
 
        <script id="changeVideo">
            sub = document.getElementById("sub");
            sub.addEventListener("click", function(){
                video.src = URL.createObjectURL(document.getElementById("file1").files[0]);
            }, false);
        </script>
    </div>
    <script id="VideoPlayer">
    	var vid = getParameterByName("vid");
    	if(vid != null && vid != ""){
    		document.getElementById("video").src = vid;
    	}
        window.addEventListener("load", function() {
            video = document.getElementById("video");
            video.volume = 0.50;
            timeField = document.getElementById("time-field");
            timeField.innerHTML = getFormattedTime()+" / "+getFormattedDuration();
            pbarContainer = document.getElementById("pbar-container");
            pbar = document.getElementById("pbar");
            playButton = document.getElementById("play-button");
            soundButton = document.getElementById("sound-button");
            sbarContainer = document.getElementById("sbar-container");
            sbar = document.getElementById("sbar");
            fullscreenButton = document.getElementById("fullscreen-button");
            video.load();
            video.addEventListener("canplay", function(){
                playButton.addEventListener("click", playOrPause, false);
                pbarContainer.addEventListener("click", skip, false);
                soundButton.addEventListener("click", muteOrUnmute, false);
                sbarContainer.addEventListener("click", changeVolume, false);
                fullscreenButton.addEventListener("click", fullscreen, false);
            });
        }, false);
        function playOrPause(){
            if (video.paused){
                video.play();
                video.style["-webkit-filter"] = "brightness(1)";
                playButton.src = "img/pause_button.png";
                update = setInterval(updatePlayer, 30);
            }else{
                video.pause();
                video.style["-webkit-filter"] = "brightness(0.5)";
                playButton.src = "img/play_button.png";
            }
        }
        function updatePlayer(){
            if (video.ended){
                window.clearInterval(update);
                playButton.src = "img/replay_button.png";
            }
            var percentage = (video.currentTime/video.duration)*100;
            pbar.style.width = percentage + "%";
            timeField.innerHTML = getFormattedTime()+" / "+getFormattedDuration();
        }
        function skip(ev){
            if (!video.ended){
                var mouseX = ev.pageX - pbarContainer.offsetParent.offsetLeft;
                var width = window.getComputedStyle(pbarContainer).getPropertyValue("width");
                width = parseFloat(width.substr(0, width.length - 2));
 
                video.currentTime = (mouseX/width)*video.duration;
            }
        }
        function getFormattedTime(){
            var seconds = Math.round(video.currentTime);
            var minutes = 0;
            while (minutes > 59){
                seconds -= 60;
                minutes++;
            }
            if (seconds < 10){
                seconds = String("0"+seconds);
            }
            return minutes+":"+seconds;
        }
        function getFormattedDuration(){
            var seconds = Math.round(video.duration);
            minutes = 0;
            while (seconds > 59){
                seconds -= 60;
                minutes++;
            }
            if (seconds < 10){
                seconds = String("0"+seconds);
            }
            return minutes+":"+seconds;
        }
        function muteOrUnmute() {
            if(!video.muted){
                video.muted = true;
                soundButton.src = "img/mute_button.png";
            }else{
                video.muted = false;
                soundButton.src = "img/sound_button.png";
            }
        }
        function changeVolume(ev){
            var mouseX = ev.pageX - (sbarContainer.offsetLeft+sbarContainer.offsetParent.offsetLeft);
            var width = window.getComputedStyle(sbarContainer).getPropertyValue("width");
            width = parseFloat(width.substr(0, width.length - 2));
            video.volume = (mouseX/width);
            sbar.style.width = (mouseX/width)*100+"%";
        }
        function fullscreen(){
            if(video.requestFullscreen){
                video.requestFullscreen();
            }else if (video.webkitRequestFullscreen){
                video.webkitRequestFullscreen();
            }else if (video.mozRequestFullscreen){
                video.mozRequestFullscreen();
            }
        }
        function getParameterByName(name) {
            var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
            return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
        }
    </script>
 
</body>
</html>



Comentarios sobre la versión: 1.0 (1)

Enyelber Altube
25 de Abril del 2016
estrellaestrellaestrellaestrellaestrella
Lo voy a probar, si esta bueno lo podría utilizar para mi radio online?
Responder

Comentar la versión: 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios

http://lwp-l.com/s3479