7 days of unlimited WordPress themes, plugins & graphics - for free!* Unlimited asset downloads! Start 7-Day Free Trial

# Skin Orman Clark's Video Interface Using jPlayer and CSS

Read Time: 12 mins
This post is part of a series called Bringing Premium Pixels to Life.
Quick Tip: Give Orman's Navigation the :target Treatment

Coding up Orman Clark's Premium Pixel designs is great fun, this time we'll have a look at his Video Player Interface! We'll build it using an awesome HTML5 video library called jPlayer along with some HTML and CSS.

## Step 1: HTML5 Base Markup

We'll start off by throwing together a blank HTML5 document, while remembering to source jQuery in the head (I'm using jQuery hosted by Google). I'll also link to the latest HTML shiv which will ensure Internet Explorer interprets and styles HTML5 elements correctly.

One last thing, you'll note that I've linked to a stylesheet too, we'll add the CSS later on in the tutorial.

Next we'll need to download jPlayer "The jQuery HTML5 Audio / Video Library". Head on over to jplayer.org and download the current release.

Go ahead and create a folder named "javascript" or "js" (or whatever you're accustomed to) in your web folder and copy jquery.jplayer.min.js into it. Next you'll need to link to this in your HTML, so add the following in your <head> section (remembering to change the path as appropriate).

## Step 3: Player Markup

We'll now add the markup we need to create the player. Don't worry if it appears overwhelming, most of this is taken from demos on the jplayer.org site and I'll explain all that's necessary later on.

Firstly, you'll see a main container for everything. We'll apply some global styles to that. Then there's the div "#jquery_jplayer_1" which the jPlayer script will target and add the video to (you'll see this id referenced in the jQuery function when we add that).

You really only need to concern yourself with whatever's inside the <div class="jp-gui"> tags. This is the main section which will contain the video controls. We'll create another couple of containers within it which all help with resizing depending on whether full screen is on or off.

## Step 4: Controls Markup

Now for the good stuff..

Here we've added our controls, all commented for clarity. To kick off, our play button followed by the pause button. These are both given suitable class names for styling later on. Next, we have a span with a class of 'separator'. Orman used some nifty little separators in the design, since these are separators with a gradient on them we'll use an image for these (though feel free to use CSS3 gradients if you're confident).

Next we create the progress bar and there are a few elements which go in to building this. First we have 'jp-progress' which is the base of the progress bar. Next we have 'jp-play-bar'. This is the cool red bar which scrolls across signifying progress of the video. Note we also use a span with a class of 'handle' here to create the little knob shown in the design.

Now for the current time and duration of the video. We'll create these once again using divs, with the classes 'jp-current-time' and 'jp-duration'. Note we also used another span class again, this time to create another separator but using a forward slash so no images will be used here. After that lot you'll see we have another separator, same as previously.

The volume buttons and bar then need to be made. First we'll create two buttons, 'jp-mute' and 'jp-unmute'. Only one of these will be displayed at a time, the other will be hidden with jPlayer. The volume bar has the same principles as the progress bar, same structure (though different class names, obviously).

If you view the file in the browser you won't see too much happening yet.

## Step 5: Adding a Video

Now the main part, we'll add a video! For full functionality and cross-browser support you'll need your video available in multiple formats. HTML5 media formats supported by jPlayer are:

• mp3
• mp4 (AAC/H.264)
• ogg (Vorbis/Theora)
• webm (Vorbis/VP8)
• wav

Various browsers support different video formats; the relevant format will be selected depending on the browser providing it's been made available. Check out caniuse.com for more information on who, what and where.

We'll also need a .png file which acts as a poster for when the movie isn't playing.

For the purpose of this tutorial I'm using a movie trailer downloaded from http://trailers.apple.com. I then converted it into the correct formats (there are plenty of free online resources to help you out here, Google away..)

So once you've converted them and created your .png poster place them somewhere appropriate in your project. After that we'll need to add an instantiation snippet to get jPlayer up and running.

Add the following to the foot of your document remembering to change the file paths to reflect your own. You'll see that we're pointing jPlayer to the "#jquery_jplayer_1" element.

Check out the jPlayer documentation for more options and attributes. OK, you should have something similar to this:

## Step 6: Video Base CSS

Before we get into adding some CSS for the control interface we'll add a background, fonts etc. to the body and also the styles for the base of the video. Go ahead and create a stylesheet, remembering to link to it in the head section of your webpage. I've also thrown in a reset just incase your browser decides to add some margins and whatnot!

After the reset rules I've added a background with an image. Next I've targeted the whole player (the video and controls), I've given it a font-family and added some box-shadows (while remembering to use the browser prefixes!). We've then given it styles for when the player is in full screen mode.

You should now have something similar to the following:

## Step 7: Basic Controls Styling

Time to start styling up the controls section! We'll first style the base gray part. We'll use a fluid-width of 100%, this is used so it'll stretch to full width when in full screen mode. I've also added a fixed height of 35px. Next we'll use a gradient for the background, I went ahead and created this using GradientApp and then cleaned it up using the Prefixr API.

Finally I've added a box-shadow to create the inset shadows, once again remembering to use the browser prefixes. I've next added some styles for the controls holder (basically a container), allowing us to center the control panel when in full screen mode. You'll see how this works later on. I've used a fixed width of 570px and centered it using margin: 0 auto;

You shouldn't see much change since the last step except for the gradient background we've just added:

## Step 8: Play and Pause Buttons

Next we'll add the play and pause buttons, along with the separator. I'll be using a sprite for all the buttons, which you can grab in the source files.

I've first defined a width and height for both the pause and play buttons, they'll both have the same dimensions. Next I've added a text-indent to push any text within the anchor links off the screen as we don't need them, we'll be using the sprite image. Finally we'll use outline:none; which will fix a problem when clicking, preventing some browsers showing a horrid blue glow around the button.

## Step 9: Progress Bar

Okay, first we'll target the progress bar base. We'll give it a solid background, add a border-radius of 5px (with the prefixes), two box-shadows, a drop shadow and an inset shadow. Next we'll add some widths and heights, both fixed. We'll then add some margin-top just to center it within the whole interface.

Next we'll add some styles for the seeking bar which shows how much the video has loaded. We'll apply a width of 0px because jPlayer will handle the actual width dynamically, and a height of 100% so it will inherit the progress bar height, filling it all up. We'll also give it the border radius of 5px and a background.

Lastly we'll create the progress bar which moves as the video plays. I'll be using an image and repeating it on the y-axis. Once again, as previously we'll add a width of 0px and jPlayer will handle the rest. Next, remember that span tag we created? This will be used for the handle. We'll be using an image for this too, and position it absolutely. We'll need to use right:XXpx; to ensure it moves along with the play bar.

## Step 10: Current Time / Duration

Time to do time (snigger) Seriously though, let's style up the current time and duration. We'll target them both first to apply some styles they'll share. The rest is basic stuff like margins.

## Step 11: Volume Buttons and Bar

We're not far from completion now, so let's handle the volume section. We'll need two buttons, the mute and unmute. We'll apply some styling to both and then the sprite to each one individually.

Note we've used outline:none; again to avoid that problematic active state. To create the volume bar we'll use a similar process to the progress bar. We'll apply a fixed width and height, give it a background, some box shadows and a border radius of 5px. The volume bar itself is transparent so we won't apply a background to it. Next we have another knob; using a span again we'll apply a background image, use position:absolute; and position it to the right so it'll move correctly.

## Step 12: Full Screen Button

We're on the last step now! All we have left is the full screen button. Using similar steps as before, we'll apply the sprite again, use text-indent to hide the text (also known as pushing-it-off-the-screen). And remembering to use outline:none; again (which admittedly could be applied to all anchors at the beginning of the stylesheet).

And our video player is complete!

Go ahead and try the full screen feature, it's awesome!

## Conclusion

By using the jPlayer plugin and Orman's delightful design, we've coded up a pixel perfect video player interface. Don't forget, jPlayer has many more tricks up its sleeve, so make sure you check out the demos and documentation. I hope you enjoyed this tutorial, thanks for reading.