0

I have made one html page. And in that video tag is added. Now after certain time videos pauses and one form comes up, And the data of that form is submitted using servlet. Now i want go back to same state of video where it was paused. What should i use in servlet to do that. Because

response.sendRedirect(request.getHeader("referer"));

goes back to starting of the page.

EDITED

i am doing this document.cookie="currentTime=video.currentTime"; on submitting of form, and this

vid.addEventListener("timeupdate", function()
    {   
        if(getCookie("currentTime")!==0){
            video.currentTime=getCookie("currentTime");
        }

in event listener, whats wrong?

2 Answers2

0

Unfortunately, there's not a lot you can do server-side to do that. But in the JavaScript on the page, you can bind event handlers to the video. Specifically, if you bind the progress event, you can keep track of where the user is. You could set a cookie when you get the progress event and overwrite it as the events come in, then when the user goes back to the page, make the video seek to the last time you saved.

1337p337
  • 36
  • 4
  • when forwarded to the previous page, how can i overwrite timing of video? – Sanket Modak Jan 31 '17 at 08:28
  • Also localStorage would help. http://stackoverflow.com/questions/11667925/save-html5-video-currenttime-before-user-leaves-or-closes-page and about overwrite time of video http://stackoverflow.com/questions/10461669/seek-to-a-point-in-html5-video – Juan Picado Jan 31 '17 at 08:41
0

You can create a different servlet for capturing form response and submit the form using ajax which will prevent refresh of the page thus saving the position of seek in video tag.

Mohd Asim Suhail
  • 2,176
  • 1
  • 16
  • 23
  • can you elaborate more on this because i am new to this.? – Sanket Modak Jan 31 '17 at 08:00
  • For submitting form you must be sending response to action url in form, instead of that create a separate servlet ( for e.g formResponse ) for capturing form response. set action in form to formResponse.And onSubmit of form send request using ajax (let me know if u not aware of ajax) on success of ajax call u can hide the form and resume the video play – Mohd Asim Suhail Jan 31 '17 at 08:06
  • i am not aware of ajax – Sanket Modak Jan 31 '17 at 08:30
  • https://jsfiddle.net/7q19Lom8/ look at this snippet, i have created a basic form and submitting its response using ajax using jQuery, you can google ajax form submission and learn about it more. – Mohd Asim Suhail Jan 31 '17 at 09:24