Button to skip html5 video to the end<button> vs. <input type=“button” />. Which to use?How can I know which radio button is selected via jQuery?jQuery disable/enable submit buttonStoring Objects in HTML5 localStorageChange an HTML5 input's placeholder color with CSSHow to create an HTML button that acts like a link?Are (non-void) self-closing tags valid in HTML5?Can I hide the HTML5 number input’s spin box?Using HTML5/Canvas/JavaScript to take in-browser screenshotsHTML5 video playing backward, detect “end” of video
When did Britain learn about American independence?
Do we see some Unsullied doing this in S08E05?
Polynomial division: Is this trick obvious?
Capital gains on stocks sold to take initial investment off the table
refer string as a field API name
How do Ctrl+C and Ctrl+V work?
Deleting the same lines from a list
Cuban Primes
Why does Taylor’s series “work”?
Why is vowel phonology represented in a trapezoid instead of a square?
Why are there five extra turns in tournament Magic?
How can we delete item permanently without storing in Recycle Bin?
Would life always name the light from their sun "white"
Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?
Is Precocious Apprentice enough for Mystic Theurge?
How come Arya Stark didn't burn in Game of Thrones Season 8 Episode 5
Is Big Ben visible from the British museum?
301 Redirects what does ([a-z]+)-(.*) and ([0-9]+)-(.*) mean
Why nobody knew who the Lord was?
What is this rubber on gear cables
Can EU citizens work on Iceland?
Why is it correct to use ~た in this sentence, even though we're talking about next week?
What dog breeds survive the apocalypse for generations?
Is it possible to pass a pointer to an operator as an argument like a pointer to a function?
Button to skip html5 video to the end
<button> vs. <input type=“button” />. Which to use?How can I know which radio button is selected via jQuery?jQuery disable/enable submit buttonStoring Objects in HTML5 localStorageChange an HTML5 input's placeholder color with CSSHow to create an HTML button that acts like a link?Are (non-void) self-closing tags valid in HTML5?Can I hide the HTML5 number input’s spin box?Using HTML5/Canvas/JavaScript to take in-browser screenshotsHTML5 video playing backward, detect “end” of video
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a video player which contain a skip button so that the user can skip the video to the end.
Here is html
<video id="video1" style="height: 100%" class="video-js vjs-default-skin" controls muted autoplay="true">
</video>
skip function
function skipVideoTime()
$('.skip_button').on('click', function ()
var vid = $("#video1")[0];
var vidDuration = Math.floor(vid.duration);
skipTime(vidDuration);
console.log(vidDuration);
)
function skipTime(time)
var vid = $("#video1")[0];
vid.play();
vid.pause();
vid.currentTime = time;
vid.play();
console.log(vid.duration);
;
$(function ()
skipVideoTime();
);
Here is console logs from the above functions
32.534
32
Now when I click the button it skip to 32 minutes because I used math floor function if I remove math floor so that it can skip to 32.534, it does not work,
what do I need to change to get what I want?
javascript jquery html html5
add a comment |
I have a video player which contain a skip button so that the user can skip the video to the end.
Here is html
<video id="video1" style="height: 100%" class="video-js vjs-default-skin" controls muted autoplay="true">
</video>
skip function
function skipVideoTime()
$('.skip_button').on('click', function ()
var vid = $("#video1")[0];
var vidDuration = Math.floor(vid.duration);
skipTime(vidDuration);
console.log(vidDuration);
)
function skipTime(time)
var vid = $("#video1")[0];
vid.play();
vid.pause();
vid.currentTime = time;
vid.play();
console.log(vid.duration);
;
$(function ()
skipVideoTime();
);
Here is console logs from the above functions
32.534
32
Now when I click the button it skip to 32 minutes because I used math floor function if I remove math floor so that it can skip to 32.534, it does not work,
what do I need to change to get what I want?
javascript jquery html html5
2
As far as I can guess, you are trying to seek the media / video at the end of its time. e.g. 32.534 sec. after that you are again callingplay()function which I think will play the video again from start. Do you really need to callvid.play()after seeking the media till its duration ?
– agpt
Mar 23 at 16:38
add a comment |
I have a video player which contain a skip button so that the user can skip the video to the end.
Here is html
<video id="video1" style="height: 100%" class="video-js vjs-default-skin" controls muted autoplay="true">
</video>
skip function
function skipVideoTime()
$('.skip_button').on('click', function ()
var vid = $("#video1")[0];
var vidDuration = Math.floor(vid.duration);
skipTime(vidDuration);
console.log(vidDuration);
)
function skipTime(time)
var vid = $("#video1")[0];
vid.play();
vid.pause();
vid.currentTime = time;
vid.play();
console.log(vid.duration);
;
$(function ()
skipVideoTime();
);
Here is console logs from the above functions
32.534
32
Now when I click the button it skip to 32 minutes because I used math floor function if I remove math floor so that it can skip to 32.534, it does not work,
what do I need to change to get what I want?
javascript jquery html html5
I have a video player which contain a skip button so that the user can skip the video to the end.
Here is html
<video id="video1" style="height: 100%" class="video-js vjs-default-skin" controls muted autoplay="true">
</video>
skip function
function skipVideoTime()
$('.skip_button').on('click', function ()
var vid = $("#video1")[0];
var vidDuration = Math.floor(vid.duration);
skipTime(vidDuration);
console.log(vidDuration);
)
function skipTime(time)
var vid = $("#video1")[0];
vid.play();
vid.pause();
vid.currentTime = time;
vid.play();
console.log(vid.duration);
;
$(function ()
skipVideoTime();
);
Here is console logs from the above functions
32.534
32
Now when I click the button it skip to 32 minutes because I used math floor function if I remove math floor so that it can skip to 32.534, it does not work,
what do I need to change to get what I want?
javascript jquery html html5
javascript jquery html html5
asked Mar 23 at 16:19
user9964622user9964622
1,35021846
1,35021846
2
As far as I can guess, you are trying to seek the media / video at the end of its time. e.g. 32.534 sec. after that you are again callingplay()function which I think will play the video again from start. Do you really need to callvid.play()after seeking the media till its duration ?
– agpt
Mar 23 at 16:38
add a comment |
2
As far as I can guess, you are trying to seek the media / video at the end of its time. e.g. 32.534 sec. after that you are again callingplay()function which I think will play the video again from start. Do you really need to callvid.play()after seeking the media till its duration ?
– agpt
Mar 23 at 16:38
2
2
As far as I can guess, you are trying to seek the media / video at the end of its time. e.g. 32.534 sec. after that you are again calling
play() function which I think will play the video again from start. Do you really need to call vid.play() after seeking the media till its duration ?– agpt
Mar 23 at 16:38
As far as I can guess, you are trying to seek the media / video at the end of its time. e.g. 32.534 sec. after that you are again calling
play() function which I think will play the video again from start. Do you really need to call vid.play() after seeking the media till its duration ?– agpt
Mar 23 at 16:38
add a comment |
1 Answer
1
active
oldest
votes
I believe you don't need to call the play() function again. because once media is seeked to the end (till its total duration), calling play() will do nothing but run the video again from beginning. Have a look at following code snippet.
var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315815%2fbutton-to-skip-html5-video-to-the-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I believe you don't need to call the play() function again. because once media is seeked to the end (till its total duration), calling play() will do nothing but run the video again from beginning. Have a look at following code snippet.
var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>add a comment |
I believe you don't need to call the play() function again. because once media is seeked to the end (till its total duration), calling play() will do nothing but run the video again from beginning. Have a look at following code snippet.
var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>add a comment |
I believe you don't need to call the play() function again. because once media is seeked to the end (till its total duration), calling play() will do nothing but run the video again from beginning. Have a look at following code snippet.
var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>I believe you don't need to call the play() function again. because once media is seeked to the end (till its total duration), calling play() will do nothing but run the video again from beginning. Have a look at following code snippet.
var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>var video = document.getElementById("myvid");
var button = document.getElementById("button");
button.addEventListener("click", function(e)
console.log(video.duration);
video.play();
video.pause();
video.currentTime = video.duration;
// video.play();
)<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<video src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" controls id="myvid"></video>
<button id="button">skip</button>
</body>
</html>answered Mar 23 at 16:41
agptagpt
3,00483978
3,00483978
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315815%2fbutton-to-skip-html5-video-to-the-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
As far as I can guess, you are trying to seek the media / video at the end of its time. e.g. 32.534 sec. after that you are again calling
play()function which I think will play the video again from start. Do you really need to callvid.play()after seeking the media till its duration ?– agpt
Mar 23 at 16:38