02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Creating a Button

Stage one in our video controller is to have a button that can control it. By the end of this video we will have a controller capable of controlling our video.

Video Transcript

00:00The next step now is I really want to create some sort of a button and that button will be basically our controller to play and
00:07Pause our video to do that. I'm going to create a new button and its type is going to be a button as well
00:13Now we're going to give it a name as well. Well, actually we're going to give it a value which will be play pause
00:19And I'm going to save that and just go into my browser to make sure that I got a new button created
00:26So I'm going to go back into safari click on refresh and now I'm going to see a play pause button
00:31Just waiting to be activated all that's left for us is to create some sort of an action that will trigger the events and trigger the reaction
00:39of our application
00:41Now the first thing that I really want is to be able to access my video to do that
00:45We're going to use one of the one of the new features of HTML 5 that we learned about was get element by ID
00:52So I'm going to go to my video and I'm going to give it an ID and I'm just going to call it my vid
00:56And I'm going to go up to my script area
00:59And I'm first going to show you how it's how we we can't do it
01:02And then I'll show you how we could do it
01:03So one is like I want to create a new vid of new variable
01:07I'm going to call it vid and I really want to fetch that my vid the only problem is my vid is not loaded yet
01:12In line 9 so that's what if I would try to go to document
01:16get element by
01:18ID and I would fetch that my vid as we saw that we could do if I save that and I'm let's say just come
01:26Here, and I just add another console dot log which basically enables us to see the value directly into our log file
01:33Which is the console that we see and we've been working with there. There's one in every single browser these days
01:39If I go back into the browser, and I just click on refresh to see what comes out in my log
01:44I'll see that the log returns the value of null
01:47The reason the log comes back with a value of null is because the video has not been loaded yet
01:52And the document didn't finish loading yet as well
01:54So what we want to do is we want to wait for the video and the document to complete to completing its loading time

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!