joaoctm123 Posted May 31, 2013 at 11:52 PM Report #510378 Posted May 31, 2013 at 11:52 PM (edited) Boa Noite, Estou aqui com um problema, que é o seguinte, eu estive a pesquisar exemplos na internet sobre HTML5 como ver a duração do video, o tempo de reprodução, etc. O que acontece é que tem 2 funções que uma dá o tempo total do video, e outra dá a o tempo de reprodução. O que acontece é que queria fazer era calcular o tempo de reprodução em segundos. Mas não estou a conseguir, segui como estava no código originalmente mas não estou a conseguir. PS: Eu criei a função convertSeconds. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>HTML5 Video</title> </head> <body> <p> <button id="play">PLAY</button> <button id="pause">PAUSE</button> </p> <video id="video" src="lol.mp4" width="800" height="600" controls></video> <p id="duration"></p> <p id="currenttime"></p> <p id="ola"></p> <script> var myVideo = document.getElementById("video"); var btnPlay = document.getElementById("play"); var btnPause = document.getElementById("pause"); var textduration = document.getElementById("duration"); var textcurrenttime = document.getElementById("currenttime"); var textseconds = document.getElementById("ola"); btnPlay.addEventListener("click", function(){myVideo.play();}, false); btnPause.addEventListener("click", function(){myVideo.pause();}, false); myVideo.addEventListener("loadedmetadata", function(){textduration.innerHTML = "Duration: " + convertTime(myVideo.duration);}, false); myVideo.addEventListener("timeupdate", function(){textcurrenttime.innerHTML = "Current Time: " + convertTime(myVideo.currentTime);}, false); myVideo.addEventListener("secondupdate", function(){textseconds.innerHTML = "Seconds: " + convertTime(myVideo.currentTime);}, false); function convertSeconds(org){ var minute = Math.floor(org*60) % 60; var second = Math.floor(org%60); var seconds = (minute*60)+second; return seconds; } function convertTime(org){ var minute = Math.floor(org/60) % 60; var second = Math.floor(org%60); return( minute + ' : ' + second); } function saltar(tempo){ var vid = document.getElementById("video"); document.getElementById("video").currentTime = tempo; vid.pause(); } </script> Momento 1 - <button onclick="saltar(8)">Saltar</button><br> Momento 2 - <button onclick="saltar(14)">Saltar</button><br> Momento 3 - <button onclick="saltar(172)">Saltar</button><br> </body> </html> Obrigado 🙂 Edited June 1, 2013 at 09:32 AM by brunoais geshi + título muito melhorado
I-NOZex Posted June 1, 2013 at 03:29 PM Report #510423 Posted June 1, 2013 at 03:29 PM espero nao ir contra as regras, mas acho que isto te deve de ajudar: http://www.chipwreck.de/blog/2010/03/01/html-5-video-dom-attributes-and-events/ B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now