navigate site menu

Become a member and get unlimited access to every course in the library. Try it free for 7 days

Create an HTML5 Video Gallery with jQuery and Dreamweaver

Create an HTML5 Video Gallery with jQuery and Dreamweaver

with Chris Converse

 


In this course, author Chris Converse develops an interactive video gallery for the web, working in a Dreamweaver environment using a combination of HTML5 with a Flash fallback, CSS, and the open-source JavaScript library jQuery. The course shows how to design the site layout and construct the code for a player that works on multiple web browsers, platforms, and mobile devices. Techniques to enable HTML5 video on Android and ensure that Internet Explorer defaults to Flash instead of HTML5 are also demonstrated.
Topics include:
  • Preparing the graphics
  • Adding and linking thumbnail buttons
  • Designing the layout
  • Adding jQuery and JavaScript
  • Including video information in the thumbnail links
  • Styling the thumbnails with CSS rules
  • Creating a DIV container to hold the video player code
  • Setting up click events for the thumbnails
  • Incorporating the FancyBox lightbox plug-in

show more

author
Chris Converse
subject
Developer, Web, Web Design, Web Video, Projects, Web Development
software
Dreamweaver CS3, CS4, CS5, CS5.5, HTML 5, jQuery
level
Intermediate
duration
1h 10m
released
Jul 28, 2011

Share this course

Ready to join? subscribe


Keep up with news, tips, and latest courses.

submit Course details submit clicked more info

Please wait...

Search the closed captioning text for this course by entering the keyword you’d like to search, or browse the closed captioning text by selecting the chapter name below and choosing the video title you’d like to review.



Introduction
Previewing the project across browsers and devices
00:04Hi! This is Chris Converse and this is a course on creating an interactive video gallery.
00:07So I want to start by showing the final project that we are going to be creating.
00:12In the Final Project folder we have two HTML files.
00:15We have an index_option_1 and index_option_2.
00:18Inside of the includes, we have two different JavaScript file options as well.
00:22Both of these options have to do with how the video player is going to work on mobile devices.
00:27So we'll take a look at those in a moment. But first let's come over to Safari
00:30and take a look at how this interactive experience is working in Safari.
00:35So when I roll over each of these thumbnails I get at a rollover state.
00:38When I click on a thumbnail it uploads a video up in a light box.
00:42And then each browser is going to use its own built-in HTML5 support to show the
00:46video controls as well.
00:47So clicking outside will make the video go away.
00:50Click on the next video.
00:51(Music playing)
00:54Close that as well.
00:55So this is how the user experience looks in Safari.
00:58In Firefox, instead of using MPEG4, which is the video format that all of the
01:02browsers and devices are going to use except Firefox, we are going to be using
01:05the Ogg Theora or OGV video file format.
01:08So again, I can come in here and clicking gets the same user experience.
01:11The controls are going to look a little different based on how Firefox's
01:14controls are going to be rendered as opposed to other browsers.
01:18(Music playing)
01:21These videos work great.
01:23Let's come into Chrome.
01:24Now Chrome doesn't allow auto play by default, so we click on the video it
01:28loads up but I do have to come down here and click Play in the Chrome browser
01:31to see these rendering.
01:35Now if your browser doesn't support HTML5 video we also have a Flash fallback
01:39that we are going to be programming in.
01:41So we have some Flash video players and a video skin that you can put into your project.
01:45So for browsers like IE 7 and 8 that don't have HTML5 video support, what's
01:49actually going to happen is it's going to use Flash instead of HTML5.
01:53So if I were to right-click on this, I would see that we are actually using
01:55Flash here instead of HTML5 video.
01:59Now the options I was referring to before have to do with how the different
02:03mobile devices are going to handle video.
02:05If we look at this running on an iPad, you will notice that the iPad user's
02:09experience is very similar to that of the computer screens.
02:12I tap on a video, an overlay comes up.
02:14I can tap on the overlay, the video will start to play right in line inside of
02:18the FancyBox overlay, and then I can also click the full-screen view to come
02:23out of the container, go into full- screen view using the device's video player,
02:27and then condense that down and go back to the lightbox.
02:30The two options that we really were talking about for mobile devices have to
02:34do with the phones.
02:35The Android platform doesn't support HTML5 video unless we use an onClick
02:40JavaScript event and we don't specify the codec. And in both cases for the
02:45iPhone and Android, we can see that the video overlay comes up.
02:48I can tap on the video and then they will each jump into their respective video
02:52players and play the video.
02:54The second option has to do with bypassing the overlay altogether since neither
02:58platform supports playing the video inside of the overlay.
03:03So the second option is to just change the link. Instead of having the link
03:07invoke the overlay,
03:08we are going to have the link change the URL to go directly to the actual video file itself.
03:13Now on the iPhone platform, this means that it opens another window in Mobile
03:17Safari requiring us to hit the Back button.
03:20And during this course we are actually going to show you how to do
03:22JavaScript detection so you can change the user experience depending on the
03:25individual devices.
03:27So I hope this sounds interesting to you and if so let's get started with
03:30the first movie.
Collapse this transcript
Using the exercise files
00:00When you download the exercise files there is going to be three items inside of there.
00:03There is an Art Templates folder,
00:05there is a code_snippets.html, and a Final Project folder.
00:09Inside of the Final Project are all of the files that we took a look at in
00:12the introduction video.
00:14There are two HTML files, an index_option_1 and an index_option_2.
00:19Inside of the includes, there are two option JavaScript files as well,
00:22option_1 and option_2.
00:24The option_1 JavaScript file is imported in the option_1 HTML file and in the
00:30introduction video, we talked about two possibilities for including support for
00:34the iPhone and the Android operating systems.
00:37So each of these options correlates to those options we looked at in
00:40the introduction video.
00:41During the course, at the end we are actually going to add in these two
00:44different options and talk about the differences between the way these are
00:47implemented and you can decide which one you want to use in your
00:50particular projects.
00:51Let me close Final Project.
00:53Code_snippets has the HTML5 video player with the Flash fallback embedded inside of it,
01:00so we are going to be using that as sort of a basis and we are going to
01:03be using JavaScript to create a variable with all of that code and dynamically
01:07inject that into our video player.
01:11And in the Art Templates folder we have a template_items.psd.
01:14This is a native Photoshop file with the slices already in place that create the
01:17design of the player.
01:19Of course you can modify this file or use the basic code for the video player
01:23and add your own design into your own project. And with that, we will start
01:27creating our project folders in the next movie and begin developing our project.
Collapse this transcript
1. Preparing the Graphics
Exporting image slices from Photoshop
00:00To start our project, let's create a new folder on the desktop
00:02called myVideoGallery.
00:09Let's open that up and then inside let's create two additional folders, one
00:14called images, one called includes.
00:22Now, with those in place, let's come back to the exercise files, let's go into
00:24Art Templates and let's open up template_items.psd.
00:27Now this Photoshop file has some slices already in place.
00:31I am going to use my magnification tool here and just zoom up a little bit.
00:36So we have three graphics we are going to export from here.
00:38Click on the Slice selection tool here. I can double-click on the first slice.
00:42This is going to be the play icon.
00:44The one over here in the center is going to be the ie_caption_transparency.
00:48Since IE 7 and 8 don't support the RGBA color specification from CSS3, we are
00:54going to have an alternate CSS file that's going to bring in this
00:57semi-transparent PNG file.
00:58So we can get a semi-transparent caption, as we saw in the introduction video,
01:02working in IE7 and 8.
01:04And then lastly we have this filmstrip graphic over here, this particular tile.
01:10We have made sure to make sure that the masking in the top area here matches the
01:14masking at the very bottom.
01:16So as this graphic tiles, depending on the height of the overall player, we are
01:19going to get a seamless transition between the images tiling up and down and
01:24this is going to be called filmstrip_tile. Let's choose OK.
01:28At this point, let's choose File > Save for Web & Devices.
01:30In the upper left-hand corner here we see the Slice tool.
01:34I am going to select the first slice, hold the Shift key, select the other two slices.
01:39In the upper right-hand corner let's make sure we have PNG-24 as the Web graphic
01:43format and then lastly let's come down and choose File > Save.
01:46Now on the desktop let's go into myVideoGallery/images.
01:50We will choose All User Slices down here in the Slices setting, then choose Save.
01:57We can see in the background the three different slices up now have been saved out:
01:59filmstrip_tile, ie_caption _transparency and play_icon.
02:03Let's come back to Photoshop.
02:06Let's close our file.
02:07So now let's close up our templates.
02:10We won't need to be going back into Photoshop for the rest of the course.
02:13And now that we have all of our graphics in place, in the next movie we are
02:16going to start by creating a brand-new HTML and CSS file and start building a
02:20layout based on these particular graphics.
Collapse this transcript
2. Setting Up the Project Files
Creating new HTML and CSS files
00:00Now that we are ready to create our HTML and CSS, let's move over into Dreamweaver.
00:05If you prefer to do this course and a code only environment we're also offering
00:09the same course in Aptana Studio and you can find that in the library as well.
00:12So with Dreamweaver running, let's come up to the File menu.
00:16Let's choose File > New.
00:18Under Page Type let's choose HTML.
00:20If you are using Dreamweaver 5 or 5.5 you can choose HTML5 as a Document Type.
00:27If you're using earlier versions of Dreamweaver you can still create HTML5
00:31documents; just Dreamweaver won't give you any sort of code hinting to help you code along.
00:37So if you're using an earlier version of Dreamweaver CS5, you are going to want
00:40to choose XHTML Transitional and then we can update the DocType, which we will
00:43take a look at in a moment.
00:44So choose HTML5. Hit Create.
00:47Now if I come over to Code view, you can change the document type from XHTML in
00:53earlier versions of Dreamweaver to !DOCTYPE HTML.
00:58So the doctype for HTML is just a really simple statement that just declares HTML.
01:05Switch back to Design View.
01:07Next, let's choose File > New.
01:09Let's create two CSS files. Start by creating the first one.
01:15Let's choose File > New and create the second one.
01:20With the second file selected or in the forefront let's choose File > Save.
01:24Let's save this into the includes directory and let's call it video_gallery.css. Hit Save.
01:36The other CSS file, let's choose File > Save.
01:39We are going to call this video_gallery_ie.
01:45This file is only going to be used for Internet Explorer 7 and 8. Let's choose Save.
01:51Lastly, let's come back to the HTML file. Choose File > Save.
01:55We are going to put this in the main root of the VideoGallery folder.
01:58We will just call this index. Choose Save.
02:03Now that our CSS and HTML files are created, let's go up to the Format menu, CSS
02:09Styles > Attach Style Sheet. Browse. VideoGallery/includes/video_gallery.css, then
02:20click Choose, then say OK.
02:23We have now created a link.
02:25You can see the related files here in Dreamweaver. video_gallery.css is now
02:29being linked to from the index.html file.
02:34At this point let's switch to Code View.
02:36We are going to need to add a few lines of code into here for Internet Explorer.
02:40The first one we are going to add is going to be a meta tag for IE9 and this
02:44is going to tell Internet Explorer 9 that it's okay to use its HTML5 rendering engine.
02:49So let's start by creating a new line after the existing meta tag.
02:55Begin the tag, meta, space, http equivalent, equiv, = "", then a forward slash and an ending tag.
03:12Inside of the http equivalent we are going to type X-UA-C, the word Compatible.
03:25We are going to add a second attribute, content = "", and inside the quotes we
03:33are going to type IE=9.
03:38So again, this will tell Internet Explorer to use its HTML
03:41rendering capabilities.
03:43The next thing we need to add is an HTML comment and inside of that comment
03:47we are going to put a conditional statement that only Internet Explorer can understand.
03:52So before the ending head tag, let's come down here and type <!--.
04:00This is the beginning of an HTML comment.
04:02Now inside of here we are going to use two square brackets and inside of
04:07here we are going to type if lt, for less than, IE 9, then we are going to end
04:20that particular tag.
04:21So basically what we are saying here is if the browser is less than IE 9, let's
04:25hit Return, let's tab in.
04:31First thing we are going to do is add in that Google shiv we talked about in
04:34the introduction video.
04:35So we are going to say script src for source = "".
04:43We are going to end the tag, then we are going to end the script tag.
04:47Now the file source we are going to point is up on Google's web site.
04:55http://html5shiv. googlecode.com/svn/trunk/html5.js.
05:23This JavaScript file will talk to Internet Explorer 7 and 8 and make them
05:28recognize all of the new tags in HTML5 through the use of JavaScript.
05:34On the next line type a beginning tag, type a link, rel for relative, = "".
05:48We are going to type stylesheet.
05:53Outside the quotes, new attribute type= "text/css".
06:05Then another attribute. href = "includes/video_gallery_ie.css"/ and then end the tag.
06:24Now after we have done that, let's add another return and we want to end this
06:30conditional statement inside of another HTML comment.
06:33So we are going to do a beginning tag, exclamation point, two square brackets,
06:39endif, the two words end if condensed down into one word, two hyphens and
06:49then the ending tag.
06:51So basically the beginning of the HTML tag starts here, the end starts here, and
06:56this square bracket indicates to Internet Explorer, which is the only browsers
07:01that will support this particular conditional statement, and it's basically
07:04saying if this is less than IE 9 we are going to import the Google shiv and we
07:08are going to import that video_gallery.ie file that we created so that we can do
07:13things like use that transparent PNG file for the captions.
07:19With that in place, let's switch back to Design view, let's choose File > Save All,
07:23and in the next movie we will start creating some CSS and HTML to create the
07:28design of our gallery.
Collapse this transcript
Adding HTML anchor links for thumbnails
00:00To get started with our layout, I first want to add some HTML to the page.
00:04So in Dreamweaver, we are going to come down to the Insert panel. So you can get
00:07to that by going to the Window menu and choose Insert.
00:10This panel you can also dock to the top of your screen, which I've done here, which
00:14turns the Insert panel into tabs.
00:18So under Layout, let's come down to the very first item and choose insert a div tag.
00:21We are going to give this a custom class name, video_gallery_container, then choose OK.
00:33When you insert a div in Dreamweaver, it gives you a sort of bounded box area
00:37indicating that there is a div and you put some default text inside so we
00:40can get a cursor inside of here and make sure that we can add things inside the div area.
00:44We are going to select some text here.
00:47Come down to the Properties panel, Shift+3 for a pound sign, hit Return.
00:53This is going to create a self link, so I can see the actual anchor tag.
00:56At this point let's switch to Code View.
00:59Inside of CodeView, I am going to format this a little bit.
01:01I will tab in the div.
01:04Let's come in and get rid of the default text Dreamweaver we added in.
01:06I will tab in the anchor tag, bring the ending div out, and I also want to get
01:12rid of the text inside of the anchor tag.
01:14I just want it to be blank.
01:17Lastly, let's get rid of href and let's add class equals, beginning and ending
01:22quote, and inside we are going to use the class called video link.
01:30With that in place, let's copy that, again a paste, Command+V or Ctrl+V, five
01:39more copies so that I have six anchor links.
01:42After the anchor tags, let's add in another div, class= "clear_both", and
01:55then let's end the div.
01:57This is going to be a class that we are going to create
01:58that's going to clear out all of the floats from the anchor tags that we are going
02:02to be setting up inside of our CSS.
02:04At this point let's switch back to Design view.
02:07Now in the Design view we can't see any of the anchor tags.
02:10They have nothing inside of them so that their dimensions are now 0 pixels.
02:14But what we are going to do in the next movie is evaluate our sketch for
02:17the design, modify your CSS files, and lock onto the classes we just added to our HTML.
Collapse this transcript
3. Preparing the Gallery Layout
Setting up and designing the outer container
00:00Now before we start creating some of the CSS rules, I want to refer back to a
00:03sketch that we created for this particular project.
00:06So I always recommend creating a sketch.
00:07This gives us the ability to sort of figure out what the user experience is
00:10going to be and give us a chance to add some of the measurements in place so
00:13that we know what we are creating inside of our CSS.
00:16So in the introduction video, we looked at the fact that the outermost container
00:19of this is going to be fluid or liquid, meaning it can actually be stretched to be
00:23whatever width the browser is or the device you are looking at the gallery on.
00:27But inside of the container, we do want to have few measurements in place.
00:30I want to set the top and bottom padding to 25 pixels, meaning nothing inside of
00:35the container can get within 25 pixels of the edges.
00:38The right-hand side we are going to leave at zero because we are going to
00:40set margins on the thumbnails, but the left-hand side I want to set a
00:43padding of 115 pixels.
00:46That way we have enough room in the left hand side to have that vertical tiling
00:49filmstrip graphic we created earlier in Photoshop.
00:52Now the other measurements we are going to be creating are going to be thumbnails.
00:55They are going to be 200 pixels wide by a 115 pixels tall and inside of the
01:00anchor tags for the thumbnails we are going to have a div to hold the caption
01:04and an image tag to hold the Play button graphic.
01:06Now these HTML elements we are not going to be adding into Dreamweaver.
01:10We are actually going to inject those with JavaScript later on in the course.
01:13So now let's go back to our Dreamweaver document.
01:17Let's go back to the HTML file and in the CSS Styles panel over here we are
01:21actually going to create some new rules inside of the video_gallery.css file.
01:27Let's come down and enter video_gallery_container.
01:33Make sure it starts with a period. Let's click OK.
01:38Now let's define the properties of this.
01:42First let's come down to the box model properties.
01:44For Padding let's uncheck Same for all, and let's add in those paddings we were
01:48looking at in the sketch.
01:48It's 25 on the top, 0 on the right, 25 on the bottom, 115 on the left.
01:54Let's move over to the border settings.
01:59Let's keep Same for all for Style, Width, and Color.
02:01I'm going to choose a solid, 2 pixel and for color, I am going to type #444.
02:06That's going to give us that sort of dark gray color.
02:14And lastly, let's come down to Background.
02:16For the Background-color let's use the eyedropper and choose black.
02:19Background-image we'll choose Browse.
02:24Let's choose filmstrip_tile.png inside of the images directory. Click Choose.
02:29For the repeat we are going to set repeat on the Y axis.
02:32We are going to set 0 position for the X and 0 position for the Y.
02:36Now at this point we will choose OK.
02:39Now we can see in the background some of the design is starting to take place,
02:45the black background.
02:46We can see the filmstrip tile graphic happening over here.
02:50The next rule we want to create is that clear_both.
02:52That's going to set the clear for all of those thumbnails we are going to be creating.
02:55Let's create a new rule, new class,.clear_both.
03:03Let's come down to Box properties here and we are simply going to come and set
03:10both for the clear property for this and then choose OK.
03:13Now that we have all of the CSS in place for the outermost container, in the
03:17next movie we are going to start by creating the CSS rules for the thumbnails.
Collapse this transcript
Conforming anchor links in thumbnail buttons
00:00Now we are going to set up the CSS rules for the thumbnails.
00:04Let's come over to the video_gallery.css file.
00:07Inside the Styles panel, let's choose New Rule.
00:11In here, we are going to come down and choose Compound.
00:15We are going to type a.videoLink with a capital L. Let's choose OK.
00:22This means we are targeting anchor links that have a class of video link on them.
00:26There are a few things we are going to want to set in here.
00:30First let's come down to the Background.
00:32I want to temporarily set a background of light gray so that we can see these
00:36anchor tags as they start to take shape.
00:37Next let's come down to the Block properties.
00:41Now anchor tags by default have inline style properties, which means they
00:44are only as wide as the content that's inside of them that is making up the hyperlink.
00:49Now in this case we have all of these empty anchor tags so they are all
00:52showing up as 0 pixels.
00:54If we come in here to Display and change the Display type from inline, which is
00:58the default, to block, that's going to change the way anchor tags behave and they
01:02are going to behave more like div tags or image objects.
01:06Let's come over to the Box properties.
01:07Let's add 200 pixels on the Width, 115 on the Height.
01:13We are going to click Apply at this point and we will now see all the
01:15anchor tags taking shape.
01:17200 wide, 115 tall, and they are sort of lining up vertically now.
01:22For Padding we are going to set 0 for all of these.
01:25For margin, we are going to uncheck Same for all.
01:27We are going to set 0 on the Top, 15 on the Right, 15 on the Bottom, and 0 on the Left.
01:35Click Apply again and we can see them space out.
01:38Let's come up to the Float properties and choose Float left. Let's click Apply.
01:43Now all of the anchor tags are going to sort of flow side by side.
01:46They are going to be 115 pixels on the left, away from that repeating filmstrip
01:50graphic, and the margins on the individual objects will make sure that no
01:54thumbnail gets within 15 pixels of the right side of each of the individual
01:58thumbnails or 15 pixels from the bottom.
02:01Now we are going to have that Play button and the caption inside of these objects.
02:10So we are going to come down to the Position settings and set the Positions on
02:13each one of these to relative.
02:15That means that the objects themselves will play nicely in the HTML code with
02:19all the other objects, but anything inside with absolute positioning will
02:23position itself relative to the object, so each of the Play buttons will
02:27position themselves based on each anchor tag and not the higher container or the body tag.
02:33Next let's go to Background.
02:35We are going to be placing a background video thumbnail graphic as the
02:38background of the anchor tags and while we are going to set the images with
02:42JavaScript, I do want to set the other properties here.
02:45So we are going to set no-repeat.
02:47We are also going to set 0 on the X and Y position.
02:53Let's go to our Border and we want to set a border because on our rollover state
02:56we want the border to show up, but we don't want to add a border on rollover
03:00because that will cause all of the thumbnails to shift around.
03:02So instead we want to add a border that we can't see in the normal state and
03:05then have it change color on the rollover state.
03:09So while keeping Same for all for Style, Width and Color, let's come in and choose solid.
03:14We are going to do 1 pixel and we are going to come in here and choose black as the color.
03:20And the last thing we want to change, let's come down to Extensions.
03:23What we want to do is under Visual effect for the Cursor, since these anchor
03:28tags don't have a href, some browsers like Safari won't actually show you the
03:31pointer tool when somebody moves their cursor over top.
03:34So we want to make sure that that's in place.
03:36So under Cursor, let's type pointer. Then we will click OK.
03:43Now in order to test this, let's come up to Dreamweaver's Live View.
03:46So in Live View I roll over each one of these items.
03:49Now I can say I get a hand cursor and each one of these is behaving like an anchor link.
03:57Let's turn off Live View.
03:58Let's create one more rule.
04:01This will also be a Compound.
04:03We want to create the hover state for all of these thumbnails.
04:09So a.videoLink:hover.
04:12It's going to add the pseudo class to those anchor tags with the class of videoLink
04:18assigned to them.
04:20Let's simply come in to the Border settings.
04:24For Color, let's come in and change it to white. Choose OK.
04:28Again, let's come in to Live View. Let's roll over these.
04:32Now when I roll over each one, I can see the border that's black, which appears
04:36to be invisible, now changes to while when I roll over these.
04:41Let's come up in Live View.
04:43Let's choose File > Save All.
04:45Now there is one rule we are going to need to set for Internet Explorer.
04:47So let's go over to the video_gallery.css and let's come in here and let's copy
04:54the entire video container css rule.
04:58Choose Edit > Copy.
05:00Let's go over to video_gallery for IE.
05:02Command+V or Ctrl+V to Paste.
05:05What we need to do in the video_gallery, Internet Explorer is not going to set
05:10the height properly on this particular object.
05:13So let's delete all of this text and let's add in a height:100% and we are also
05:22going to need to add a padding value.
05:25padding-top of 20 pixels.
05:34Let's choose File > Save and then back to our HTML file.
05:37Now that we have the CSS in place for the thumbnails and the outermost
05:42container, we are going to start the next movie by creating our own JavaScript
05:45file and hooking in FancyBox and jQuery.
Collapse this transcript
Adding jQuery and JavaScript to your project
00:00To create our own JavaScript, we are going to come up to the File menu in
00:02Dreamweaver, come down to File > New.
00:05Let's choose JavaScript from the Page Type and click Create.
00:10Right away, let's choose File > Save.
00:14Make sure we're in the Includes directory inside of myVideoGallery.
00:21Let's name this video_gallery.js.
00:25Now, let's go out to the exercise files.
00:27Inside of Final Project, let's open up the Includes directory here, and inside
00:32of includes we want to bring over the jQuery file and the FancyBox folder.
00:38I am going to Option+Drag out a copy of these over into my Includes directory
00:43in the myVideoGallery.
00:44Now, for FancyBox, we've got written permission from Janis Skarnelis to include
00:48this with our project.
00:49So thank you Janis!
00:51We also have a copy of jQuery.
00:53You can also download jQuery from jquery.com as well and you can learn more
00:57about FancyBox on fancybox.net.
01:00So now in the Includes directory we have our jquery, fancybox, and the
01:03video_gallery.js file.
01:05Now, let's hook these into our main HTML file.
01:09So let's come over to index.html.
01:12Let's click into Code View and let's scroll to the very top of the document.
01:17Right after the video_gallery.css, let's hit a Return, and in the Insert menu,
01:23under Common, let's come over to the Script.
01:26Let's click on Script for insert a new JavaScript.
01:30Under Source, we're going to click this folder.
01:32The first file we need to bring in is the jquery-1.6.1.minified, click Choose, click OK.
01:40Let's hit a Return.
01:42Let's add another script.
01:43Let's bring in FancyBox.
01:44Let's click Source, go to fancybox-1.3.4, fancybox folder, and then here let's
01:51come down and grab the packed version. Click Choose, click OK.
01:57Let's hit a Return.
02:00Let's bring in the style sheet associated to FancyBox.
02:03Let's come up to the Format menu, CSS Styles > Attach Style Sheet, Browse,
02:10myVideoGallery/includes/fancybox-1.3.4/ fancybox folder, and come down and
02:16choose the CSS file. Then choose OK.
02:21Dreamweaver will default to putting that right before the ending head tag.
02:25Now lastly, we are going to bring in our custom JavaScript file.
02:28Let's come up to the Insert panel. Insert JavaScript.
02:31Let's come back out to the Includes directory, video_gallery.js, then
02:37click Choose. Then say OK.
02:39Now that we've hooked in all of the necessary JavaScript and CSS files, in the
02:45next movie we are going to modify our HTML a little bit and then start
02:48writing our first scripts.
Collapse this transcript
Adding video information to the thumbnail links
00:00Now to create the video thumbnails I only want to use an anchor link and I want
00:03the anchor link to have all the information about the video, the size, and the
00:07caption information.
00:09So what we're going to do is add attributes to the anchor tags inside of here
00:13that will allow us to lock onto those pieces in jQuery and build the thumbnails
00:18and also have them trigger FancyBox and play the video we want to watch.
00:20Now, we already have the class associated into each one of these.
00:23So I'm going to come in here in the first anchor tag and we're going to add
00:29another attribute called videowidth="", and this is going to be the width of the
00:36actual video file this is going to link to.
00:38The very first video was 640 pixels wide.
00:41Next is going to be videoheight.
00:46That's going to be ="360" pixels, videofile, another attribute, equals, and here
00:59we're going to type ocean_medium, space, and then lastly, videocaption=, and
01:14we'll say Caption for, and we copy ocean_medium. It goes here.
01:24So now that one anchor link sets up its class, sets up the video width and
01:29height, the video file, and the video caption, and again we're going to pick all
01:32that up with jQuery.
01:33Now, back in the exercise files, there's an HTML file called code_snippets.
01:39Let's open that file up in Dreamweaver.
01:41So in here are a bunch of different pieces of code we're going to be using for
01:44the rest of the course.
01:46At the very top, I have all of the anchor link attributes.
01:49These link to all of the video files we're including with this particular course
01:53with all of the sizes and sample captions.
01:56Let's start by grabbing all of these anchor links.
02:00We'll choose Edit and Copy.
02:02This will just save you time from having to type all this information in.
02:05Let's switch over to our HTML.
02:07Let's scroll down and let's grab all of these anchor links.
02:13Command+V or Ctrl+V to paste.
02:14I'm going to format these a little bit.
02:21Now, we'll get all of our anchor links in place.
02:24Let's choose File > Save All.
02:26Back to the exercise files.
02:28We also want to take the video directory here.
02:31Let's drag a copy of those over into our project.
02:41If we look inside the video directory, we can see that we have a JPEG file
02:45which is the thumbnail.
02:46We have the cycling_large, cycling_ large.ogv, the two different file formats.
02:51Again, MPEG4 for most of the browsers in mobile devices, and the OGV, Ogg
02:56Theora file for Firefox.
02:57Now the file name here is matching the file name inside the video file and
03:03notice we're not using .JPEG, .MP4, or .OGV.
03:06Again, we just want to know the exact name.
03:08This will be the variable piece we'll pull out, and then we're going to
03:11construct the rest of the HTML in the video player from that.
03:14Now that we have all of the data that we need inside of the anchor links, in the
03:18next movie, we're going to write some JavaScript to pick out these variables and
03:21write additional HTML into these anchor links.
Collapse this transcript
4. Finalizing the Thumbnail Design
Adding HTML to the thumbnail links with JavaScript
00:00So now what I want to do is start over in JavaScript and take each one of these
00:05anchor links and I want to add an image into each one of the anchor tags.
00:10I want to add a div with the caption and I want to set a CSS property of the
00:13background image with the corresponding thumbnail graphic, so that each one of
00:17these anchor tags that are now 200 x 115 wide will have a background graphic
00:22inside of them in addition to the Play button and the caption.
00:26So to start this, let's go over to the video_gallery.js file.
00:28So in here, we're going to start our first jQuery statement, which is going to
00:32be the document ready.
00:33So I am going to type the dollar sign, beginning and ending parentheses.
00:38Inside the parentheses, type document. Outside the parentheses, I'll type ready,
00:47beginning and ending parentheses, semicolon.
00:50Inside of the ready we're going to type function, beginning and ending
00:55parentheses, beginning and ending bracket.
00:57Let's get the cursor inside of the brackets and let's split that open.
01:01We'll add a few lines into here.
01:03So inside of here I want to search through and find all of the anchor tags with
01:08the videoLink class.
01:09So we'll start it off with dollar sign, beginning and ending parentheses, two
01:14tick marks inside for a string literal, a.videoLink.
01:21Outside of there, we're going to type each, beginning and ending parentheses.
01:25Inside of the each, we're going to type function, beginning and ending
01:31parentheses, beginning and ending bracket, semicolon at the end, and then we're
01:35going to split that bracket open as well.
01:37So now, inside of videoLink each(function), which means each anchor tag that
01:46jQuery finds, we want to do this following set of instructions.
01:51First, we're going to set up a variable.
01:57The first one is going to be called thumbnailFilePath.
02:02We're going to set that equal to two tick marks, video/, which is targeting the video folder.
02:11After the string literal, let's add a plus sign, dollar sign, beginning and
02:16ending parentheses, jQuery statement for this, which means the actual anchor tag
02:21in each statement that's being found.
02:23So we want to find (this).attr for attribute, beginning and ending parentheses.
02:31Inside there, two tick marks for string literal, videofile and then plus,
02:41two tick marks and a semicolon. Inside the tick marks, .jpg.
02:47So we're setting the thumbnailFilePath to video/, the value of the attribute of video file, plus .jpg.
02:57This will give us the actual JPEG file that's associated to that video.
03:00Next line, videoCaption variable is going to equal, dollar sign, beginning and
03:12ending parentheses, (this).attr for attribute, beginning and ending
03:19parentheses, semicolon.
03:22Inside of the attributes, two tick marks, videocaption.
03:28Now, there are the two variables set up. Now let's take each one of the anchor
03:35tags and add some code into each one of them.
03:37So with a dollar sign, beginning and ending parentheses, (this).css, beginning
03:46and ending parentheses, semicolon.
03:49So now what this is basically doing is setting CSS properties onto this object.
03:55First, we're going to do two tick marks, a comma, and then two tick marks again.
04:01Those are going to be two individual string literals.
04:03The first one is the property of CSS we're going to set, background-image.
04:11The second one is going to be the actual value of that.
04:15So url, beginning and ending parentheses.
04:18We're still inside the string literal. Inside of the parentheses of the url statement,
04:23we're going to put two more tick marks. To end the first string literal, start a second.
04:29Two plus signs.
04:30Let's go grab thumbnailFilePath, hit Copy, Command+C, or Ctrl+C and then Paste.
04:36So now we're going to set the CSS background to whatever that thumbnail path is.
04:44Let's hit Return, dollar sign, beginning and ending parentheses, (this).html.
04:54So now we're going to add HTML inside of the anchor tag. Beginning and ending
04:58parentheses, semicolon.
05:02Inside of the parentheses, two tick marks for a string literal, and let's create
05:07some HTML. Beginning html tag, div, class, equals, two full quotes, caption.
05:23Let's end that tag.
05:24Outside the string literal, let's hit a plus sign.
05:27We'll hit a second plus sign. Two more tick marks for string literal.
05:33I am going to end the div tag.
05:38Let's start a brand new tag. image, class, equals, two quotes, play.
05:50Outside the quotes, but still inside the string literal, space, source, equals,
05:57two quotes. Inside the quotes, images/play_icon.png.
06:10Outside the quotes, forward slash and then end the tag.
06:14Next, let's come up and grab the videoCaption variable name, copy that to the
06:18clipboard, and we're going to paste it right here where we're concatenating the
06:22two string literals.
06:24So basically, we're going to dynamically add a background-image property.
06:28We're going to add a div with a class of caption, with the actual caption text,
06:33and then after that, we're going to add an image with a class of play with the
06:37source equaling the images play_icon.png that we created earlier from Photoshop.
06:41So at this point, let's choose File > Save.
06:44Let's go back to our index.html file.
06:48Let's click on Live View.
06:49So then when we view this inside of Dreamweaver, we're now seeing each of the
06:54captions being picked up, cycling_ large, ocean_medium. The Play buttons are
06:58being added in here as well.
07:00Everything inside is still being treated like an anchor tag, because everything
07:03is inside of an A tag.
07:05We see our Pointer tool, because we set the CSS for cursor equals pointer.
07:11Now, in order to be able to tell that the code is actually being implemented or
07:14added into here, what we're going to do is come out of Live View, choose File >
07:19Save All, and now let's come down and preview this in a browser.
07:22So now inside of Safari, if we go to Safari's Preferences menu and in the far
07:30right under the Advanced tab, you want to make sure you turn on this tool called
07:33Show Develop menu in menu bar.
07:35What this will do is add this Develop menu up here at the top.
07:39But another nice feature here is we can actually inspect this particular page
07:43and see what's actually happening. Since if we did a View Source, we would only
07:47see the anchor tags,
07:48all of the HTML being added by JavaScript is happening in RAM and is part of
07:52the Pages Document Object Model in the browser, but again we wouldn't see
07:56that in the source code.
07:57So I'm going to right-click, come down here, and choose Inspect Element.
08:03When I do that, Safari is going to give me this diagnostic tool here which is
08:08going to allow me to see everything that's happening inside of my document.
08:12So notice the anchor tag. I can toggle this open and I can see that I do have a
08:16div and an image tag inside of each one of these items.
08:21So if I grab the very first one, click on the div tag, I can see that
08:24highlighted here, and the Image tag highlighted here.
08:27So again, even though these aren't in my source code, jQuery is adding all
08:31of these items in to each one of these anchor tags when it sees the class videoLink.
08:35Let's come back to Dreamweaver.
08:38Let's preview this in Firefox.
08:41If you happen to like Firefox more than Safari, Firefox has a plug-in you can get
08:45called Firebug which will put a little icon down here in the lower right.
08:49Firebug will do something very similar.
08:51We can right-click, choose Inspect, and see again exactly the div and anchor
08:57tags that are being added by JavaScript into our document.
09:00Now that we're successfully injecting HTML into our anchor tags, in the next
09:04movie we're going to work on some CSS to style these and position the items
09:08inside of the anchor tags to match the layout.
Collapse this transcript
Styling the HTML inside the thumbnail links
00:00Now we're going to add some CSS rules to style those thumbnails.
00:04Back in the index.html file over here in the CSS Styles panel,
00:08make sure you have the video_gallery. css selected and not the jquery.fancybox.
00:13Let's add a rule into video_gallery.css.
00:16Let's come down to compound path and what we're going to do is choose
00:21a.videoLink div.caption.
00:30So what this is going to do is only target divs or the caption class if they're
00:35inside of an anchor tag with the video link class.
00:40Let's choose OK. First thing we're going to do is come down to Positioning.
00:44We're going to turn on absolute positioning for these items.
00:47Let's come down to the Box properties. The width we're going to set to 180 pixels wide.
00:53Now for Padding we're going to uncheck Same for all and for padding top
00:58we're going to pick 15.
00:59We're going to put 10 on the right, 10 on the bottom, and 10 on the left.
01:05Now the reason we're making this 180 is that the padding on the right and left
01:09is going to add to the overall dimensions of this object's width.
01:12So 180 plus 10 on the right and 10 on the left gives us 200, which matches
01:18exactly the width of the anchor tag we set in the a.videoLink with four anchor tags.
01:25Let's come under Type. For Color let's choose white, for Font-family let's come
01:31and choose Arial, for Font-size we're going to choose 12 pixels, and lastly down
01:37on Positioning, we're going to set the Bottom to 0 pixels.
01:41This means that the object will be absolute positioned, but will always want
01:44itself to the bottom of the thumbnail.
01:46So as we add more content for captions, it's going to grow vertically, starting
01:50from the bottom to upwards.
01:53Let's choose OK at this point.
01:54Now let's come up here and choose video_gallery.css.
01:58Let's go into Code View.
02:02So in the code for the CSS, we do want to add one attribute inside of here that
02:06we can't do in Dreamweaver's interface, although it has support for it, and that
02:09is the RGBA color space for CSS3.
02:14So under div caption after the bottom setting of zero pixels, let's come in
02:18here and start to type background. Code hinting will come up.
02:24background-color, semicolon, space.
02:27We're going to choose rgba. Beginning and ending parentheses, semicolon.
02:34So rgba color is a way that we can specify colors in CSS3.
02:38Basically we set four parameters, the three colors for red, green, and blue, and
02:42then the final value for transparency.
02:44So we're going to do 0, 0, 0, which is black, no colors for red, green, or blue,
02:52and then a comma and then the last one is going to be transparency. I'm going to put in .5,
02:57which means 50% transparent.
02:59So we're basically painting the background with a semi-transparent color.
03:03While we're in the Code View here, let's scroll up.
03:07We also saw that we had rounded corners on the container in the
03:10introduction video.
03:11So let's come up here and add some around the corners and here as well.
03:16So inside of video_gallery_ container we're going to add border radius,
03:19Dreamweaver's code hinting is going to kick in.
03:22It's supporting this in the Code View, just not in the visual area.
03:26So border-radius 12 pixels. Now right now on the IE is supporting
03:33straight-up border radius. Both Firefox and Safari, their rendering
03:38engines, which are WebKit for Safari and Mozilla for Firefox, need to have
03:43their own flag on in front of this.
03:46So we're going to type -moz-border-radius: 12px.
03:59I'm going to copy that and paste it and I'm going to change moz to webkit.
04:03Let's switch back to Code View. Back to Design View.
04:13Now to test this so far, let's come up to Live View. Now that Live View kicks in,
04:20I can see that the captions are now aligning to the bottom. They have a 50%
04:24transparent background with white type.
04:25Let's come out of Live View.
04:28Let's go over to our video_gallery.css.
04:31Let's create a new rule. Compound path.
04:35We're going to do a.videoLink img.play.
04:44So now we're targeting images that have a play class if they're inside of an
04:48anchor tag with the videoLink class.
04:51Let's choose OK. In here we're going to come down to Positioning.
04:55Let's set position to absolute.
04:57Let set the Top to 25 pixels and let's set the Left to 75 pixels.
05:06Choose OK. Let's come back to Live View. Now we're centering each one of these items inside
05:12of their anchor tag.
05:14Now as I've been mentioning, Internet Explorer 7 and 8 does not support RGBA
05:19color space so getting that semi- transparent background in IE7 and 8 can't
05:23be done with this method.
05:25So what we're going to do here is we're actually going to create a class
05:28inside of video_gallery.ie to target the div caption and use the background graphic instead.
05:34So let's go into video_gallery.css.
05:39Let's scroll down and let's grab the a.videoLink.caption. I'll just copy this whole rule.
05:47Let's jump over to video_ gallery.ie.css. Set a few lines.
05:52Let's paste that in.
05:53Let's get rid all of the attributes in there and here we're going to
06:01type background-color: none, semicolon.
06:11Next we're going to type background- image. Hit a space. I'm going to come down
06:12here and hit Browse.
06:22Images directory, we're going to grab the ie_caption_transparency, click Choose,
06:26then a semicolon. Hit File > Save.
06:31Let's come over to video_gallery.
06:32Let's save that and then back to html.
06:34Now that we have all of the CSS and design work in place, we have our thumbnails
06:40automatically creating background graphics, creating the captions, putting in
06:44all of the imagery, and we have the CSS that's styling everything.
06:47What we have left to do now is to create the player code, have a place for it on
06:52the page, and then invoke the FancyBox for the individual videos.
06:55So let's start by creating an area for the player code in the next movie.
Collapse this transcript
5. Setting Up the Video Player Code
Creating a div container to hold the video player code
00:00Now FancyBox gives us a couple of ways that we can look load content into the lightbox.
00:04The method we're going to choose is the inline method, where we can take code
00:08that inside of the HTML page and use that to load it in.
00:12So we need to create a container in order to hold our code and then we're going
00:15to use that container to target with jQuery and dynamically write the HTML that
00:19we're going to need.
00:22So to start let's switch over to Code View inside of the index.html file.
00:25Up to the div tag that's got the video gallery container class on it,
00:31let's start a new tag. div styles equals two quotes.
00:37Let's end the div tag.
00:41Inside of the style we're going to type display: none, so this will be
00:49hidden from the viewers.
00:51Inside of this div we're going to add another div. ID equals two quotes, end that
00:59tag, and the div tag.
01:02The ID is going to be videoPlayer.
01:06This is going to hold all of the HTML5 and Flash fallback HTML code that we'll
01:11need to build activate our videos in the multiple devices and browsers.
01:15So in our next movie we're going to go into JavaScript file and create the code
01:19base that's going to populate this area.
Collapse this transcript
Setting up click event for thumbnails
00:00Now in order to generate the HTML that we're going to need to be placed inside
00:03of the videoPlayer container here, let's switchover to our video_gallery.js.
00:10Over here I'm going to clean up our script a little bit. Remove
00:13some of the extra whitespace.
00:15Now after the videoLink each function we're going to create a brand new script.
00:21Dollar sign, beginning and ending parentheses, two tick marks for string literal.
00:27.videoLink. Outside of the parentheses, I'm going to type click, beginning and ending
00:38parentheses, semicolon.
00:40Inside of the parentheses, function, parentheses annd brackets.
00:46Let's split the brackets.
00:50So now each time somebody clicks on an anchor tag with a videoLink class, we're
00:54going to run a series of instructions.
00:57So first off we want to setup a series of variables, so var videoFile.
01:05That's going to equal dollar sign parentheses this, .attribute. String literal inside
01:17of the attribute, videofile.
01:23Next variable, videoPoster. That's going to equal dollar sign parentheses, this,
01:34end parenthesis, .attribute, beginning and ending parentheses semicolon.
01:43Two tick marks for a string literal inside of attribute.
01:45We're going to put videofile in there as well.
01:49Next line, variable videoWidth. This is going to be equal to, we want to
02:01make sure that this is specified as a number, so we're going to type number,
02:06beginning and ending parentheses, semicolon. Inside of the parentheses,
02:11dollar sign, beginning and ending parentheses, this .attr, beginning and
02:21ending parentheses, two tick marks for string literal inside of the
02:26attribute, videowidth.
02:30One more, another variable. videoHeight. This is also going to equal a number.
02:41Beginning and ending parentheses, semicolon, inside dollar sign, beginning and
02:46ending parentheses, this, inside of the parentheses .attr, beginning and
02:53ending parentheses, string literal, inside videoheight.
03:01Now with our four variables setup, in the next movie we're going to seup our
03:04HTML code as a large variable and then replace each of these variables into
03:08that HTML block.
Collapse this transcript
Updating HTML5 video code and playing video in the lightbox
00:00Now the next variable is going to be the variable that's going to hold all of the HTML code.
00:07So we are going to type var videoCode equals two tick marks and a semicolon.
00:17Now let's go back to the exercise files.
00:20Let's open up the code_snippets.html.
00:23What we are going to do in here is we are going to be using this HTML5 player code.
00:29So it starts off with the video tag. The video tag has a width and height
00:33specified, controls, autoplay. Autoplay is not going to work in every browser.
00:38For example, it doesn't work on mobile devices and it doesn't work in Chrome,
00:42but we can put it in here, because it will be supported in some browsers.
00:46And inside the video tag we typically specify multiple sources.
00:50The first source we are going to pick is the video ogg or Ogg Theora format.
00:55This is what's going to be used by Firefox.
00:57After that we are going to pick MPEG4. This is going to be used by all of the
01:00other devices that we looked at in the introduction video.
01:04And then if neither of these work or the browser doesn't support the video tag,
01:08it's going to see this object and embed tag, which is all of the code that
01:11we need to run Flash.
01:13So the same video file, the MPEG4, is going to be loaded into an FLV player
01:17embedded inside of a Flash video skin.
01:19Now the way Flash takes in additional variables is with a query string variable here.
01:25So we have player.swf?.
01:28And then we say videoFile equals and we pick the actual file names.
01:32All of the variables that we need to set, I have put a letter x in here, so the
01:36height, width, actual video file, the skin, the individual players, everything
01:41is specified in here with an x.
01:42If we scroll down a little bit further, what I have done here is I
01:46condensed all of the whitespace out of the code and I have actually gone and
01:50replaced the axis with the actual variables that we just created.
01:54So we are going to select this entire block of code here and copy this to the clipboard.
02:00Let's switch back to video_gallery.js and inside of the two tick marks for
02:05the string literal, we are simply going to hit Paste and paste all of this code in here.
02:10So now all of this HTML code becomes part of this one variable and each one of
02:14these variable pieces that we've defined up here is going to get replaced out.
02:19So every time we click an anchor link with a videoLink class, all of these
02:23variables are going to get picked up from the individual anchor we clicked.
02:27This video code here is going to be modified with all of those different values,
02:32and after that's done what we are going to do is specify that all of this code
02:36get written to a specific point in our HTML file.
02:40So on another line let's type dollar sign, beginning and ending parentheses.
02:45Inside of here two tick marks for string literal. Pound sign, which specifies an ID.
02:50I am going to say videoPlayer.
02:54That's the name of the div we added to the HTML file, .html, beginning and
03:01ending parentheses, semicolon, and let's come up here and grab the videoCode name
03:06and copy that to the clipboard.
03:08Let's come down to the parentheses inside of the html and hit Paste.
03:14So now every time we click on that link, after all of the variables are defined
03:18and the videoCode has been modified, we are going to take all of that code and
03:22put it into the videoPlayer area.
03:26Once that's done we need to invoke FancyBox.
03:28Now typically FancyBox works by attaching the fancybox class onto an object like
03:35an anchor tag, but in this case we are going to call it manually.
03:38So we are going to use $.fancybox, because we want to have all of
03:46these things happen first.
03:47We don't want it to happen on click.
03:49So $.fancybox, beginning and ending parentheses. Inside of here we are
03:55going to do beginning and ending bracket.
03:57Then we are going to split the bracket open, put a semicolon after the parentheses.
04:04Inside of fancybox let's add some values. Two tick marks for string literal,
04:12transitionIn :, space, two tick marks, fade.
04:20That's going to be the first parameter. Comma, next line.
04:24Two tick marks, transitionOut :, space, two tick marks, another string literal, fade, comma.
04:42Two tick marks, string literal, overlayColor, overlay, all lowercase, Color :, space,
04:55two tick marks, #000.
04:58This is going to be black. Comma, next line.
05:03Two tick marks string literal, overlayOpacity :, space, two tick marks, string literal,
05:15.6 for 60%, comma. Then lastly, two tick marks, href :, space, two tick marks, and in here we are going
05:26to put #videoPlayer.
05:31No comma on the last item, and then we have the ending tag here.
05:36So again, instead of having FancyBox attached on the click event we are going to
05:40let the click event run all of these values, update the player code, and then we
05:44are going to manually call FancyBox and target the videoPlayer container that
05:49holds all of the code.
05:51So at this point let's go File > Save All.
05:54Now let's switch back to index.html. Let's choose File.
06:00Let's preview this in our browser. Let's hit Reload.
06:05Now when I click on the link, we should see the FancyBox pop-up and the
06:09video start to play.
06:10(Bicyclist: Yeah.) (Car revving)
06:16These controls down here are the default for Safari.
06:19As we look at different browsers,
06:20we will see different sort of player controls.
06:22This is up to each browser on how they want to support HTML5 video
06:25and what internal video playback mechanism they have built- in.
06:29Also notice the size of this.
06:31I am going to click on another video.
06:32which has a smaller size.
06:34(Waves crashing)
06:36(Music playing)
06:39So each one of these videos has a different size specified in the anchor links.
06:42(Male speaker: To separate the oil from the rest of the olives. Then this?)
06:48(Music playing)
06:51I am going to hop back over to Dreamweaver.
06:53Let's choose File > Preview in Browser just to make sure this is working in
06:57Firefox with the OGV format.
06:59Let's hit Reload, click on our links.
07:04(Waves crashing)
07:04(Music playing)
07:09So those are working as well.
07:10So now in the next movie we are going to take a look at some code that we can
07:13put into our JavaScript to change the user experience on mobile devices and how
07:18we can activate these HTML videos to work in Android as well.
Collapse this transcript
6. Choosing Experience Options for iOS and Android
Activating video for Android and bypassing the lightbox
00:00Now this user experience that we've programmed for computer desktop browsers
00:04will also have a very similar user experience on the iPad.
00:07Unfortunately, the emulators that we run on our computers don't have access to
00:10the actual hardware on the devices they can decode video for HTML5.
00:14So instead we made a quick recording of what the user experience looks like on
00:17an iPad. You will notice that the iPad screen comes up, I can tap on a video.
00:22We see the video come up in an overlay, but it doesn't auto-start.
00:25Auto-start doesn't work on most mobile devices to save on bandwidth.
00:29So I do tap on the video inside of the overlay and then that will start the video to play.
00:33Now on the iPad the video does play inline, so placed right inside of FancyBox.
00:38That means I can go in and hit the full- screen mode and then use the built-in
00:42QuickTime Player to go to full- screen view, and then when I come out of
00:45full-screen view it goes back into playing inside of the FancyBox overlay.
00:49And then tapping outside that area will bring me back to the original page.
00:53The iPhone is going to have a very sort of similar approach, where we can see
00:57the FancyBox come up, and when we tap on the video, instead of playing inline
01:00it will actually go to the other player.
01:02Now Android can do the same thing but Android requires we manipulate our code a
01:06little bit in order to get that to work.
01:08So when we go back to our exercise files, we want to go back to the
01:11code_snippets file, and if we scroll down, the piece of code we want to try for
01:16Option 1, which is to get the Android environment to play much like the iPhone
01:20environment, is we are going to use the code here under Option 1.
01:23What we are going to do here is create a variable called checkBrowser and then
01:28we can run a standard JavaScript function to take the userAgent and then set
01:32the entire string to lowercase, just in case if there's any capital letters in
01:35the device navigator's name.
01:37Then we're going to set another variable that says, is this Android?
01:41And then we're going to index, the userAgent, and look for the word android in there.
01:46Then if it is greater than negative one, which means it's true, it did find the
01:50word Android, we are going to run an if statement and say if Android is true we
01:55are going to do two things.
01:57First, we are going to take the codec flag off of the source inside of the
02:02HTML5, so when it says source MPEG 4,
02:05we are going to take the type out of there. So we are going to remove this attribute.
02:10Next we are going to add an onclick, this.play.
02:13This is a JavaScript code that needs to be added on the video tag for Android.
02:17Now these two things are not part of the spec so far for HTML5. They don't hurt
02:22anything, but I would rather remove these only if it's Android and keep the code
02:28in its pristine format for the rest of the browsers.
02:31So let's come in here and let's select all of this code.
02:35We are going to hit Copy.
02:37Let's go back to video_gallery.js, and after fancybox we can hit a few
02:41lines and hit Paste.
02:43I'll just format this in a little bit.
02:47So now basically what's going to happen is everything is going to happen as
02:51expected before, and if we look in the code up here at the top, we can see
02:55here's the type="video/mp4".
02:57We're going to actually remove this, if this Android, and on the video tag
03:03itself inside of here we are going to add the onclick.
03:07And now with this in place, I'll bring up a video that's showing the iPhone and
03:10the Android operating system, running this particular project and showing the
03:13common user experience.
03:16So notice I can click on each of the videos, the lightbox comes up.
03:19Neither operating system will actually play the video as an auto-play, but I can tap on
03:23the video in the overlay and they will each jump over to their respective
03:26players, and play the video.
03:27Now in the Android device I hit the Return button to go back to the original screen;
03:31 on the iPhone I click the Done button in the upper left-hand corner.
03:35Both of them bring us back to the original screen. I can tap anywhere outside of
03:39the overlay and go back to the original screen.
03:42Now back in Dreamweaver the second option we are going to look at is instead of
03:45having the overlay come up, if we're on an Android device or an iPod or an
03:49iPhone, we can instead change the link to point right at the videos,so that
03:55they play in their respective players and we don't have that extra step of
03:58looking at the overlay.
03:59So to do that, let's go back to the video_gallery.js file.
04:04Let's come in here and delete the Option 1 code we put in.
04:08We are also going to take out the fancybox code.
04:12Let's go back to our code_ snippets and let's go down to Option 2.
04:16Inside of Option 2, we do something very similar where we have a checkBrowser
04:19variable and we check the UserAgent, set it to lowercase, and then we are going to run three checks.
04:25We are going to check for Android, we are going to check for iPhone, and we are
04:28going to check for iPod.
04:29Now the iPad has a very similar play experience as the browser so we are not
04:33going to detect for that one.
04:35Then in this line we are going to check isAndroid with that two pipes here,
04:40which is the Or condition, or is this the iPhone, or is this the iPod.
04:45If it is, we are going to change the window location. This is JavaScript's way
04:48of doing it refresh on the URL.
04:51So even though the fancybox might start, what's going to happen here when
04:55the script runs is it's going to change the URL of the browser to point to the video.
05:00If any of these is not the case, so we are on a computer or an iPad, then we are
05:05actually going to run FancyBox like we did before.
05:07So we are going to copy from the variable checkBrowser all the way through
05:12the else statement.
05:13We are going to copy that to the clipboard, go to video_gallery, and right after
05:17the player code, we are going to paste all of this content in here instead.
05:21I will format this in a little bit.
05:27Now what this is going to do, I'll bring up a video here showing what this
05:30user experience will look like. The webpage is going to load like before.
05:34Now when I tap on the videos, they are going to jump right to their respective video players.
05:39So notice Android will jump right over to the video player and it will even
05:41rotate the video so it takes up the most amount of screen real estate.
05:45The iPhone will play the video in its orientation mode, so here we are
05:49looking at portrait mode.
05:50Now the only real difference here is when I hit the Back button on Android, we
05:54go back to the web page.
05:56When we hit the Back button on the iPhone, we go back to a blank web page.
06:00So what happens on the iPhone when we tap the video and change the location with
06:03JavaScript, it actually opens a new window within the Mobile Safari browser.
06:09So these are two really different sort of user experiences. One solution might
06:13be to only redirect the window location if it's an Android device, since
06:17Android's Back button will go right back to the web page, and let the iPhone work
06:21the way Option 1 works, which doesn't require any additional coding from the way
06:25the iPad and computer screens work.
06:27Now that we've got our user experience pretty consistent across all of the
06:31HTML5 supporting browsers and devices, in the next movie we were going to move
06:34our Flash assets over for IE 7 and 8 and make a few minor tweaks for our CSS to
06:39finish out the project.
Collapse this transcript
7. Taking Care of the Final Details
CSS tweaks and the Flash video player
00:00Now, two last things we want to do in our CSS file.
00:02First, let's go back to a.videoLink in the CSS panels with the index.html file open.
00:09Let's come back to our Background setting and let's come in here and take off
00:11that background color.
00:13We had put gray in there so that we could actually see the dimensions of our
00:16in-line anchor links being changed to block display types.
00:20So we'll just take that off.
00:22Let's create one more rule.
00:23Let's come down to Tags.
00:27Let's choose the body tag.
00:30Let's come in here to Background.
00:31Let's just make the background black.
00:35Under the box model, for Padding, let's just put about 20 pixels of padding so
00:39that the video probably doesn't touch the outermost edges.
00:42Now again, your video player can work self-contained so you can put this into
00:46any particular project or website design you currently have as well. Let's click OK.
00:52Lastly, let's come back out to our files.
00:54So in the myVideoGallery folder are all of the files we've been working on in this course.
00:59In the Exercise Files, inside the Final Project there are two additional files
01:04we're going to need.
01:05These are two Flash files that we need to bring into our main root as well
01:10and what these will do is if the browser does not support HTML5 video, such as
01:14IE 7 and 8, then what's going to happen is our script is going to load in
01:18this lynda.com video_player, this first file here, and inside of there is an
01:23FLVPlayback component that's going to load the video_skin file, which gives
01:27us all the controls.
01:28So we are going to select both of these files.
01:31I am going to hit Copy or Option+Drag, paste them into our original file.
01:36With all of these files in place, now we have the full user experience of what
01:40we looked at in the introduction video available inside of the myVideoGallery as well.
01:44Now with all of these files in place, in the next movie we'll talk a little bit
01:47about where you might want to go from here, including resources on lynda.com for
01:51more information on HTML5 video and Flash video.
Collapse this transcript
Conclusion
Where to go from here
00:00Now, if you are interested in more information on video on the web, there are
00:03two really great authors up on lynda.com.
00:05One is Steve Heffernan who has an HTML5:
00:07Video and Audio in Depth, and the other is Lisa Larson-Kelley, who has a course
00:12on publishing video with the Flash platform.
00:14So, both of these resources will give you much more in-depth information about
00:18publishing both an HTML5 video and Flash video.
00:21Now, in the course we just completed, if you're going to be working with a series
00:25of videos that are all exactly the same size, you might want to go back,and
00:28look at either the creating an interactive infographic or the learn to create
00:32your own photo gallery, the first two courses I have on lynda.com.
00:36In both of these cases, we have user experiences where clicking on a particular
00:39link actually changes the HTML content within the page.
00:43So instead of changing the photography inside of the page or in the information
00:48graphic instead of clicking and changing the city information, you can actually
00:51send that HTML5 code over to these other areas as well.
00:55So you can invoke new videos within the same user experience.
00:59So I hope you found this course really inspiring and helpful and I really
01:02appreciate you watching.
Collapse this transcript


Are you sure you want to delete this bookmark?

cancel

Bookmark this Tutorial

Name

Description

{0} characters left

Tags

Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading
cancel

bookmark this course

{0} characters left Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading

Error:

go to playlists »

Create new playlist

name:
description:
save cancel

You must be a lynda.com member to watch this video.

Every course in the lynda.com library contains free videos that let you assess the quality of our tutorials before you subscribe—just click on the blue links to watch them. Become a member to access all 100,877 instructional videos.

start free trial learn more

If you are already an active lynda.com member, please log in to access the lynda.com library.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Access to lynda.com videos

Your organization has a limited access membership to the lynda.com library that allows access to only a specific, limited selection of courses.

You don't have access to this video.

You're logged in as an account administrator, but your membership is not active.

Contact a Training Solutions Advisor at 1 (888) 335-9632.

How to access this video.

If this course is one of your five classes, then your class currently isn't in session.

If you want to watch this video and it is not part of your class, upgrade your membership for unlimited access to the full library of 1,934 courses anytime, anywhere.

learn more upgrade

You can always watch the free content included in every course.

Questions? Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com.

You don't have access to this video.

You're logged in as an account administrator, but your membership is no longer active. You can still access reports and account information.

To reactivate your account, contact a Training Solutions Advisor at 1 1 (888) 335-9632.

Need help accessing this video?

You can't access this video from your master administrator account.

Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com for help accessing this video.


site feedback

Thanks for signing up.

We’ll send you a confirmation email shortly.


By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked