Our seeker Sucks, let's make it better
The new html5 features are still not 100% solid one of these unsolid features is the seeker functionality. AS our video player is playing we really want to tie in our seeker to update and reflect the changes in the video. In this video we will listen in to our video and as it changes positions we will update our seeker. Making our seeker a two way perfection.
Video Transcript
00:00All right, so the next step we really want to tie the scrubber with the video as it's playing back
00:04So let's let's make that happen
00:06Back in our editor what I want to do and we could delete all this because we we already
00:11Configured everything that we need to in here
00:13The next step is I want to actually want to listen to the video when it's at when its position is changing
00:18To do that I could add into the video player another event listener
00:23This event listener would listen to time update
00:27The time update would be called on every time the time updates
00:32So every time the time updates are on time update function will be called
00:35What do we want to do in it?
00:37We want to do and it's something very similar to what we did in the on seek only the exact opposite
00:42Now in this case in scenario what we want to do is we don't want to change what's inside of our current time
00:48But what we want to do is we want to change actually our scrubber so to do that
00:53I'm going to approach our seeker and in the seeker itself what I want to do is I want to update the value
00:59Now I know the value right now because I set it to be between 0 and 100
01:03Then I want to basically find the actual current position of our video, which is the video dot current time
01:09I want to divide that by the video duration
01:12Once I get this value
01:14I want to duplicate it by 100 because the value is going to be between 0 and 1 and
01:19That's all I really had to do to be able to do the exact opposite of what I was doing in the on seek
01:24So now whenever the time updates in our information, it should update our seeker. So let's see that happen
01:31So if we go into Safari again, and I'm going to click on refresh this time around when I click on the play button
01:36You'll see as the video is playing our scrubber will be moving
01:39not only that once we click on our scrubber will see that our scrubber is going to be working much more better and the
01:45reason is is because
01:47Our time in our video is changing as well
01:49And as the time in our video is changing will it will update the seeker again making sure that it
01:55Refreshes and rerenders our seeker making it more stable than it was if we wouldn't have done it in that way
02:00and now we could actually move our seeker at any point in our video at any time and we could also pause and play the
02:07video and have it move automatically with our video and we've just created a complete seeker that has basically a
02:13Range input that basically has both the capability of us pushing in time and moving to wherever we want
02:20And we also have the capability of automatically updating the information based on the event that happens update time in our video
02:27Component that gets refreshed every time our time changes in our video now
02:32Don't forget we still have one problem and that one problem is when we initially start our
02:37Application and we start scrubbing the scrubbing is invalid and we're creating an error
02:41We'd love to avoid errors and avoid giving users issues of that nature in the next video
02:46We'll try to figure out a way how we could solve that problem
