Table of Contents for
Graphics and Multimedia for the Web with Adobe Creative Cloud: Navigating the Adobe Software Landscape

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Graphics and Multimedia for the Web with Adobe Creative Cloud: Navigating the Adobe Software Landscape by Jennifer Harder Published by Apress, 2018
  1. Navigation
  2. Cover
  3. Front Matter
  4. Part I. Welcome to the Adobe Creative Cloud. Where Should You Begin?
  5. 1. Entering the Software Maze or Labyrinth
  6. Part II. Working with Photoshop to Create Web Graphics and Animations
  7. 2. Getting Started
  8. 3. Color Choices: CMYK, RGB, Grayscale, and Index
  9. 4. Saving or Exporting Your Files for the Web
  10. 5. Actions to Speed up File Conversion and Slicing Tools
  11. 6. Tools for Animation
  12. 7. Tools for Video
  13. 8. Other Miscellaneous Items in Photoshop That You Can Use for Web Design
  14. 9. Putting It into Practice with Photoshop CC
  15. Part III. Working with Illustrator to Create Web Graphics
  16. 10. Getting Started with Illustrator CC
  17. 11. Color Choices: CMYK, RGB, and Grayscale
  18. 12. Saving or Exporting Your Files for the Web
  19. 13. Actions to Speed up File Conversion and Slicing Tools
  20. 14. Tools for Animation and Video
  21. 15. Other Miscellaneous Items in Illustrator That You Can Use for Web Design
  22. 16. Putting It into Practice with Illustrator CC
  23. Part IV. Working with Animate to Create Animations, Movies, and HTML5 Canvas
  24. 17. Getting Started with Animate CC
  25. 18. Color Choices: RGB
  26. 19. Importing Your Artwork
  27. 20. Import Your Audio and Video
  28. 21. Working with the Timeline Panel
  29. 22. Exporting Your Files to the Web
  30. 23. Other Miscellaneous Items in Animate that You Can Use for Web Design
  31. 24. Putting It into Practice with Animate CC
  32. Part V. Working with Media Encoder to Create Audio and Video Files
  33. 25. Getting Started with Media Encoder
  34. 26. Working with Your RAW Video Files (AVI and MOV)
  35. 27. Working with Your RAW Video Files and Converting Them to Audio
  36. 28. Working with Your RAW Video Files and Converting Them to an Image Sequence
  37. 29. Putting It into Practice with Media Encoder CC
  38. Part VI. Working with Dreamweaver: Adding Images, Animations, and Multimedia to HTML5 Pages
  39. 30. Getting Started with Dreamweaver CC
  40. 31. Working with Images and Tags
  41. 32. Working with CSS
  42. 33. Working with Images for Mobile Web Design
  43. 34. What Is JavaScript?
  44. 35. Working with Bootstrap, Templates, Library Items, and the Assets Panel
  45. 36. Working with Video, Audio, and Animations
  46. 37. Additional Options to Apply Images in Dreamweaver
  47. 38. Final Testing, Getting Ready to Upload Your Site
  48. 39. Putting It into Practice with Dreamweaver CC
  49. Part VII. Further Dreamweaver Integration with Other Adobe Products for Websites
  50. 40. What Other Programs That Are Part of Adobe Creative Cloud Can I Use to Display My Graphics or Multimedia Online?
  51. Back Matter
© Jennifer Harder 2018
Jennifer HarderGraphics and Multimedia for the Web with Adobe Creative Cloudhttps://doi.org/10.1007/978-1-4842-3823-3_36

36. Working with Video, Audio, and Animations

Jennifer Harder1 
(1)
Delta, BC, Canada
 

In this chapter, you look at how to add your HTML5 video, audio, and canvas animations as an animated composition or OAM file. You’ll also briefly look at a few other options that Dreamweaver has available for adding related multimedia.

Note

This chapter does not have any actual projects; however, you can use the files in the Part 6 folder to practice opening and viewing for this lesson. They are at https://github.com/Apress/graphics-multimedia-web-adobe-creative-cloud .

Whether or not your site contains templates and library items is up to you. At some point, you may want to add some animation, audio, or video files to your template-based or non-template-based pages. In this chapter, you deal with working with these types of files. You are interacting with the Files panel, Insert panel, and Properties panel when adjusting the code. Refer to Figure 36-1 to see how the Insert panel in the HTML tab contains all the media tags that you look at in this chapter.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig1_HTML.jpg
Figure 36-1

The Insert panel contains various multimedia tags

Inserting HTML5 Video

As you saw in earlier chapters, Photoshop CC, Animate CC, and Media Encoder CC can be used separately or in combination to create video for the web. The following are the type of video formats that are acceptable for HTML5:
  • MP4 (.mp4)

  • WebM (.webm)

  • Ogg Theora (.ovg)

In Part 5, you learned about these three formats and how to use Media Encoder to create an MP4, also known as H.264. It is the most commonly used format for video on the Internet. To create the other two formats Webm and Ogg, you need to acquire an additional plug-in for Media Encoder from a third-party provider or find a freeware software (the Miro Video Converter) to create these formats. Refer to Part5 for this information. In most cases, MP4 video is sufficient for your website; however, if you are concerned with backward compatibility, then you want to make sure you have the additional formats.

Streaming and Embedded Video or Have The Video On Your Own Site?

For a website developer who is building a website for a client, the question is whether or not to upload to a site like Vimeo or YouTube with Media Encoder, or keep the HTML video files on their own site. When you upload your video to YouTube, you can utilize its fast streaming quality on your site. You can then embed the video using an <iframe> and a link on your page (src) to keep the site fast and play the video seamlessly; for example,
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY">
</iframe>

The final code (ID) from W3schools is the link code to the uploaded video on YouTube; in this case, the width and height are defined in the <iframe>.

If you would like to learn how to utilize the autoplay, playlist, loop, and control features within the link, check out www.w3schools.com/html/html_youtube.asp .

If your clients have a powerful enough server, it is better to use HTML5 and set up the video on their site, as you see in a moment. With large videos that run over 5 minutes or more, make sure to run tests; otherwise, you may experience slow load times or broken streaming. Learning how to insert HTML5 video on your own site gives you a better understanding of how video works.

Setup and Testing

If you have not created the video for you own site, you may want to review the video chapters for Photoshop, Illustrator, Animate, and Media Encoder. Once you have rendered your video, make a folder called video or videos in your site’s root directory folder, and put your video files in there. In addition to keeping them organized, you may want to create subfolders, such as mp4, webm, and ogg, if you plan to have a lot of footage in theses formats. Also remember to give your video distinct names that are meaningful to you. This way, you can easily locate a video file if you need to replace it. Figure 36-2 shows how this looks in Dreamweaver’s Files panel in the root folder.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig2_HTML.jpg
Figure 36-2

In the Files panel there is a video folder that has all the formats organized

Note

You may have older Flash files (.swf) for older browser compatibility; they are not a requirement because the Internet is moving away from this format. Some browsers do not support streaming these files. In the Hot Glass Tango, there is no SWF folder.

Besides the video files, you want to make sure that you have a JPG poster image, also known as a splash screen design . This is the image that the audience sees when the HTML5 video is not playing as the file first loads. Make sure that the image has the same dimensions as the video file; in this case, 640×480.

To insert the video, go to the Insert menu’s HTML tab and locate the HTML5 video icon.

Find the place on your webpage that you want to insert the video links, place the cursor in that spot in Code view or Design view, and click the HTML5 video icon in the Insert menu. Refer to Figure 36-3.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig3_HTML.jpg
Figure 36-3

In the Insert panel you can scroll down and locate the tag for inserting HTML5 video

This inserts the HTML5 video tag.
<video controls></video>
If you select this tag in the Properties panel, you can see which links and settings you need to start adding to your video. Refer to Figure 36-4.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig4_HTML.jpg
Figure 36-4

In the Properties panel, when you select the video tag, you can see there are many setting options for attributes

  • ID: The same as ID for all other tags. Add a name for your video here. Accessed by CSS or JavaScript.

  • Class: You can add a class to your video. Note that you are not able to alter some settings of the video’s design, but you can add a border around the video or center the tag.

  • W and H: This is the width and height of the video in pixels that you set in Media Encoder or whatever video editor you chose to export your file for the web. Remember, if you are using more than one source of the same video or a poster image, make sure that they are all the same width and height to prevent distortion in your layout.

  • Source: This refers to the link to the main video that displays, in this case it is the MP4 video; if you do not have an MP4, you might make one of your other formats the source, but I recommend MP4 as the primary link.

  • Poster: This is the link to an image that displays when your video is first downloaded, and the Play button has not yet been pressed. If you do not create a poster, the first frame of the video is used instead. Usually, a poster is a JPG file that you design as a title page in Photoshop. You find the poster in your images folder and then link it with the Folder icon in the Properties panel.

  • Title : Refers to the title attribute of the video tag.

  • Fallback text : If none of your video formats play in an older browser, you can add text here to let your clients know that they have to upgrade. You can add a message, such as “Your browser does not support HTML5 video.”

  • Controls : This is for the video’s player area, to see the controls check the check box; it is the default setting so that the user can control when to start or pause the video or move to a different point with the sider. It also hides or shows the volume controls and screen size settings. By unchecking this option, the controls for the user may be unavailable when they view the video in their browser.

  • Loop: This allows the video to loop and play many times. This is generally left unchecked by default.

  • AutoPlay : This allows the video to start playing as soon as the page loads. The attribute does not work on all mobile devices. It is generally left unchecked by default.

  • Muted : The sound is initially turned off when the video loads. This is generally left unchecked by default. If you don’t want audio in your video, then make sure to remove it when you render your file.

  • Preload : Specifies the method used to cache the video when it loads. Its default is set to none, but you can also choose auto (load the entire video when the page loads) or metadata (load only metadata when the page loads) from the drop-down menu. If AutoPlay is selected, this area is ignored. Refer to Figure 36-5.
    ../images/466782_1_En_36_Chapter/466782_1_En_36_Fig5_HTML.jpg
    Figure 36-5

    Preload options for video in the Properties panel

  • Alt Source 1 : This is the next available video source after the main source link. In this case, you locate a WebM video, as this is the next popular setting for browser compatibility. If you do not have a video in this setting, you can leave this link blank.

  • Alt Source 2 : This is the next available video source after the Alt source 1 link. In this case, you would locate a OVG video, as this is the third popular setting for browser compatibility. If you do not have a video in this setting, you can leave this link blank.

  • Flash Fallback : You can add a flash fallback link to a SWF file here; however, if your video does not have this source option, or if you are not using SWF files, you can leave this link blank.

Once you are done, your Properties panel for the <video> tag should look something like this. You can see this in the video.html file and Figure 36-6.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig6_HTML.jpg
Figure 36-6

The set up for the video tag

The code looks something like this:
<video width="640" height="480" id="movie_gt" class="responsive-video" title="Hot Glass Tango" poster="images/poster_cover.jpg" controls="controls">
  <source src="video/mp4/movie_glass_tango_part2.mp4"type="video/mp4">
  <source src ="video/webm/movie_glass_tango_part2.webmhd.webm" type="video/webm">
  <source src= "video/ogg/movie_glass_tango_part2.oggtheora.ogv" type="video/ogg">
  <p>Your Browswer does not Support HTML 5</p>
</video>

Within the <video> tag, first the poster attribute and then each video <source> is listed in order of compatibility; if none work, use the fallback text in a paragraph or <p> tag.

Additionally, you may want to edit this code further for each <source> tag. In Code view, click a source tag. In the Properties panel, you can look at each source separately. You can add an ID to each source, as well as a class, or alter the link just for that video source. Refer to Figure 36-7.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig7_HTML.jpg
Figure 36-7

Add an ID to each video source in the Properties panel

The <source> tags look like this:
<video width="640" height="480" id="movie_gt" class="responsive-video" title="Hot Glass Tango"  poster="images/poster_cover.jpg" controls="controls" >
<source id="mp4_vid"  src="video/mp4/movie_glass_tango_part2.mp4 type="video/mp4">
  <source id="webm_vid"  src="video/webm/movie_glass_tango_part2.webmhd.webm" type="video/webm">
  <source id="ogg_vid"  src="video/ogg/movie_glass_tango_part2.oggtheora.ogv"type="video/ogg">
  <p>Your Browswer does not Support HTML 5</p>
</video>

Adding IDs are useful if you need to call up some additional JavaScript, as you see in Chapter 39.

The final thing that you can do is add a codec to the type attribute. It is important to add at least the type and codecs. These help the browser determine whether it can decode the files.

Here in Code view, I have altered the code slightly with the codec for each source.
<video width="640" height="480" id="movie_gt" class="responsive-video" title="Hot Glass Tango" poster="images/poster_cover.jpg" controls="controls" >
<source  id="mp4_vid"  src="video/mp4/movie_glass_tango_part2.mp4"  type='video/mp4; codecs="avc1.42E01E,mp4a.40.2"' >
<source  id="webm_vid"  src="video/webm/movie_glass_tango_part2.webmhd.webm"   type='video/webm; codecs="vp8,vorbis"' >
<source  id="ogg_vid"  src="video/ogg/movie_glass_tango_part2.oggtheora.ogv" type='video/ogg; codecs="theora,vorbis"' >
          <p>Your Browser does not support HTML5 video.</p>
        </video>

Note

You may get an error message after adding these codecs in Dreamweaver’s Output panel, but in this case, you can ignore it because this is the standard way of setting up the codec. Refer to Figure 36-8.

../images/466782_1_En_36_Chapter/466782_1_En_36_Fig8_HTML.jpg
Figure 36-8

Dreamweaver may throw a warning on how the quotes are used, but you can ignore the warning

If there are any changes in this setting, you can check https://en.wikipedia.org/wiki/HTML5_video .

The Track Tag

One further tag that you may encounter within your video tag is the <track> tag for media elements. It is new to HTML5 and is not yet listed in the Properties panel. However, you can add it manually in Code view. Track is used for specifying subtitles, caption files, or other files containing text that should be visible when the media is playing. This setting is not required for your video and audio to run; it is an optional setting. Here is an example:
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="French">

At this point, you might want to test your video and links in various browsers to make sure the media is playing correctly.

Mobile and Video Scaling

As with image <img>, videos are scaled or optimized for mobile devices and large monitors. You can add a width or a max-width (so it does not scale beyond a certain resolution) and a height of auto so that the video scales proportionately.
.responsive-video {
    max-width: 100%;
    height: auto;
}

You can learn more about this at www.w3schools.com/css/css_rwd_videos.asp .

Can You Insert Video into a Background Using CSS?

Like an image, you can insert video into a background using CSS, but it is simply behind other <div> and not using in the CSS property background image. This could be useful on an intro or index page, where the movie is behind a small amount of text that overlays the video while it plays with the controls removed. Objects moving in the background can be distracting. A better option is to use a GIF animation (no audio) within the background-image property. Or use a <canvas> animation from Animate CC because elements are better controlled and maintained.

If you’re looking for an example of video in the background, check out www.w3schools.com/howto/howto_css_fullscreen_video.asp , which uses a combination of HTML, CSS, and JavaScript to control the video with a single button.

Inserting HTML5 Audio

As with video, you can add an HTML5 audio player to your website. Before HTML5 audio, sound files could only be played with plug-ins like Flash, so audio on websites is a relatively new idea. As you saw in with Media Encoder, HTML5 accepts three formats:
  • MP3 (.mp3)

  • WAV (.wav)

  • Theora Ogg (.ogg)

In Media Encoder, you can create MP3 files and WAV sound files, but for Ogg, you need to acquire a third-party plug-in or use a free program like Miro Video Converter. Safari and Internet Explorer do not support Ogg, but Chrome, Firefox, and Opera do. In most cases, MP3 and WAV audio are sufficient for your website; however, if you are concerned with backward compatibility, then you want to make sure that you have the other formats.

Setup and Testing

If you have not created the audio for you own site, you may want to review the audio section for Media Encoder in Part 4. Once you have your audio, make a folder called audio or sounds in your site’s root directory folder and put your audio files in there. In addition, to keep them organized, you may want to create subfolders, such as mp3, wav and ogg, if you plan to have a lot of audio in these formats. As with video, give the files a distinct name. This way, you can easily locate an audio file if you need to replace it. Figure 36-9 shows how this could look in Dreamweaver’s Files panel.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig9_HTML.jpg
Figure 36-9

The audio files added to an audio folder in the Site Root folder in the Files panel

To insert the audio, go to the Insert menu’s HTML tab and locate the HTML5 audio icon. Refer to Figure 36-10.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig10_HTML.jpg
Figure 36-10

In the Insert panel, locate the HTML5 audio tag to insert audio into your webpage

Find the place on your webpage that you want to insert the audio links; place the cursor in that spot in Code view or Design view, and click the icon in the Insert menu.

This inserts the HTML5 video tag.
<audio controls></audio>
If you select this tag in the Properties menu, you can see which links and settings you need to start adding. Refer to Figure 36-11.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig11_HTML.jpg
Figure 36-11

The Properties panel with audio tag selected

  • ID : This is the same as ID for all other tags; add a name for your audio here. It is accessed by CSS or JavaScript.

  • Class : You can add a class to your audio. Note that some settings you are not able to alter such as the default browser audio’s design, but you can add a border around the audio area or center it.

  • Source : This refers to the link to the main audio that displays; in this case, it is the MP3 audio. If you do not have MP3, you might make one of your other formats the source, but I recommend MP3 as the primary link.

  • Title : Refers to the title attribute of the audio tag.

  • Fallback Text : If none of your audio plays in a browser, you can add some text here to let your clients know that they may have to upgrade. You could add a message such as “Your Browser does not support HTML5 audio.”

  • Controls : This is for the audio’s player area to see the Controls check the check box, it is the default setting so that the user can control when to start or pause the audio or move to a different point with the sider. It also affects the appearance of volume controls. If unchecked, the user cannot control the audio while listening to it in the browser.

  • Loop : This allows the audio to loop and play many times. It is unchecked by default.

  • AutoPlay : This allows the audio to start playing as soon as the page loads. This attribute does not work on all mobile devices. It is unchecked by default.

  • Muted : The sound is initially turned off. It is unchecked by default.

  • Preload : Specifies the method used to cache the audio when it loads. Its default is set to none, but you can also choose auto (load the entire audio when the page loads) or metadata (load only metadata when the page loads) from the drop-down menu. If AutoPlay is selected, this area is ignored. Refer to Figure 36-12.
    ../images/466782_1_En_36_Chapter/466782_1_En_36_Fig12_HTML.jpg
    Figure 36-12

    Choose a preload property from the properties menu

  • Alt Source 1 : This is the next available audio source after the main source link. In this case, you locate a WAV audio as this is the next popular setting for browser compatibility. If you do not have an audio in this setting, you can leave this link blank.

  • Alt Source 2 : This is the next available audio source after the Alt source 1 link. In this case, you locate a Ogg audio as this is the third popular setting for browser compatibility. If you do not have an audio in this setting, you can leave this link blank.

Once you are done, your Properties panel for the <audio> tag should look something like Figure 36-13.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig13_HTML.jpg
Figure 36-13

The audio settings have been added to the Properties panel

The code looks something like this:
<audio id="audio_gt" title="Sound File" controls="controls" >
  <source   src="audio/intro_005.mp3"  type="audio/mp3" >
  <source   src="audio/intro_005_1.wav"  type="audio/wav" >
  <source   src="audio/intro_005_1.oggvorbis.ogg"  type="audio/ogg" >
          <p>Your Browser does not support HTML5 audio.</p>
        </audio>

Within the <audio> tag, which defines the sound content, each audio <source> that defines the media resource is listed in order of compatibility and finally if none of these sources work the Fallback Text in a paragraph or <p> tag is displayed.

You may want to edit this code further for each <source> tag. In code as with the <video> tag view click a source tag within the <audio>. In the Properties panel, you can look at each source separately. You can add an ID to each source as well as a class, or alter the link just for that audio source. Refer to Figure 36-14.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig14_HTML.jpg
Figure 36-14

Add an ID for each audio source using the Properties panel

The <source> tags then look like this:
<audio id="audio_gt" title="Sound File" controls="controls" >
     <source  id="a_mp3"  src="audio/intro_005.mp3"  type="audio/mp3" >
     <source  id="a_wav"  src="audio/intro_005_1.wav"  type="audio/wav" >
     <source  id="a_ogg"  src="audio/intro_005_1.oggvorbis.ogg"  type="audio/ogg" >
          <p>Your Browser does not support HTML5 audio.</p>
        </audio>

Now the browser can detect which audio or alternate audio files it wants to choose.

IDs are useful if you need to reference additional JavaScript.

Unlike <video> sources, you do not need to add an attribute codec for audio. For more information, refer to https://en.wikipedia.org/wiki/HTML5_Audio .

At this point, you might want to test your audio and links in various browsers to make sure that the media is playing correctly.

Can You Insert Audio into a Background Using CSS?

Like video, you can hide the audio controls so that the sound cannot be turned off by the user. Keep in mind that this might be annoying to some users if the sound is very loud or they don’t like music. This is not a good practice. It is generally better to provide users some control options, like a button to mute, lower the volume, or turn on the sound by choice.

You can apply sound to <div> elements with CSS background images that can alter or change using CSS3 transitions and transforms or make a sound using JavaScript when they are hovered over (mouse-enter) or clicked. Sound can have many uses on a website that user’s can interact with. However make sure they have the option of turning off the sound as well.

Audio CSS Aural

A CSS feature for audio that you might not be aware of is aural style sheets. These style sheets convert text into audio for people who are visually impaired and require a screen reader or a speech synthesizer. The Internet should be for everyone, so if you want more information on how to add an aural style sheet, check out www.w3schools.com/cssref/css_ref_aural.asp .

Using CSS Designer panel when you create an external style sheet as in Chapter 33. You can instead under conditional usage (optional) choose a for media a setting of aural, instead of screen or print. Refer to Figure 36-15.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig15_HTML.jpg
Figure 36-15

Rather than create a style sheet for screen or print, you can create one just for aural

Insert a Canvas Element

In Part 4, you were introduced to the HTML5 Canvas. I compared it to ActionScript 3.0 and all its features. A canvas or <canvas> element draws or animates graphics quickly via scripting like JavaScript. An HTML5 Canvas FLA file was exported along with a compressed OAM file, and the result was a generated group of files:
  • a folder called images containing images

  • a folder called sounds containing audio, generally MP3 or WAV files

  • a JavaScript file (.js)that is linked and interacts with the HTML5(.html) file that is created

  • an HTML5 file (.html) that contains the <canvas> element that contains the animation. When you looked inside this file you found internal inline CSS, internal JavaScript and a link to JavaScript on an external library site (Create JS) that helps control the animation.

  • If you opened the generated OAM package, besides the above mentioned, you would also find XML files that control setting and the generated a poster image(.png).

You can also have a small video (MP4) inside the <canvas> that is part of the animation; this is created using the components panel. This appears as a separate linked file along with the aforementioned files.

Importing Animate Canvas into Dreamweaver

Once you have exported these files from Animate CC and brought them into Dreamweaver CC, you see that it contains many of the HTML5 tags that you reviewed in Chapter 31. At this point, it is up to you how you want to work with the <canvas> in the HTML file and incorporate it into your website.

Option 1

If you are planning for it to be an index or intro page that is not part of the template, you may just make a copy of this file with the new name and then continue to edit it with minor alterations, such as using CSS to center the <canvas> element, alter the background, add some text, add navigation links, or anything else that makes this page match your theme for your website.

At this point, make sure that you add your external JavaScript, images, and sounds to the correct folders in your root directory site. For your canvas animation you may want to keep a separate folder “sounds” from the one called “audio” if you have different sounds from different programs or alter this folder name during the Animate CC export. Publish in the Basic tab. It is more difficult to alter this folder link outside Animate; however, the link to the MP3 audio file is found in the generated external JS file in a section called lib.properties. Open this file and look for the manifest; and there you find the path to the sounds. If you have trouble locating this line, use Dreamweaver CC and select Find ➤ Find in Current Document. Refer to Figure 36-16.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig16_HTML.jpg
Figure 36-16

Locate a line of code within a current document

Enter the word sounds , as in Figure 36-17.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig17_HTML.jpg
Figure 36-17

While in the external JavaScript file, you can use the search text box to find a line of code

Then find the path that you want to alter. Your file should look slightly different from Figure 36-18.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig18_HTML.jpg
Figure 36-18

The line of code where the link to the audio of the canvas is found

If you plan to alter the name of the file or replace it, use the Find tool to make sure that the parts of the file name match the new name throughout the JavaScript; make the changes carefully. Whatever audio alterations you make, always test that the sound still works correctly.

Option 2

When working with an HTML5 canvas from Animate, if you are planning on adding it to a template-based page, make sure to copy each part of the code from the original file into the corresponding point in your new page. In Code view, for example, JavaScript code and <meta> tags that were in the <head> of the original now go into the <head> editable area of the template-based page. You may need to add the JavaScript onload="init();to your template. If you already have JavaScript using this function, you don’t have to add it again.
<body onload="init();>

Then add the other code in the <body>, including the <canvas>, into a specific <div> element on your page. Make sure to save and test the file links and JavaScript. You may need to adjust the CSS because it may not align the way you want it to at first. This is a laborious task. For template-based pages, there is a much cleaner way of working with the code—by using an OAM or animated composition.

Canvas Element Created Without Animate

You don’t need to use Animate CC to create all of your <canvas> elements. If you are creating still images on a <canvas> element, you can use Dreamweaver to do the work.

In your document (in either Code view or Design view), choose the Canvas in the HTML tab. Refer to Figure 36-19.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig19_HTML.jpg
Figure 36-19

Use the Insert panel to create a canvas tag

This creates the <canvas> tag with a canvas ID.
<canvas id="canvas"></canvas>
Figure 36-20 shows how it appears in the Properties panel.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig20_HTML.jpg
Figure 36-20

In the Properties panel you can view the canvas tag

You can set the width and height as you would in Animate for the stage. Refer to Figure 36-21.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig21_HTML.jpg
Figure 36-21

In the Properties panel, set the width and height of the canvas tag

As you saw in Animate CC, this program makes it quite easy to create graphics for the <canvas> element container. The canvas is used to quickly draw graphics (with color and gradients) with JavaScript formatting. If you aren’t familiar with JavaScript formatting, this could be a challenging task, so Animate is an excellent choice for complex animations.

There are resources if you want to draw basic shapes or words on a canvas and copy this code into Dreamweaver’s Code view to edit further.
Here is an example of how some code could be written:
<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// Create gradient
var grd = ctx.createLinearGradient(0,0,200,0);
grd.addColorStop(0,"blue");
grd.addColorStop(1,"red");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10,10,150,80);
</script>

Note

The <canvas> element is interactive and responds to JavaScript events. You can program for user actions, such as click buttons and finger movements. These elements are used for gaming. Do not mix the game code you create in Animate CC with those you hand code yourself in Dreamweaver. I find that you should only use the JavaScript code that is compatible with the CreateJS library while in Animate CC, because it works with the frames per second feature of Animate CC. Trying to copy JavaScript code directly into an Animate HTML5 Canvas (.fla) Action panel from a site like W3Schools might work for a still image, but usually ends in animated graphics not functioning or having a jerky motion.

Insert Animated Composition or OAM

In Animate CC, when you export an HTML5 Canvas file, you also have the option of exporting an OAM file, also known as an animated composition. OAM and the canvas file are the same in that they both can contain animations, but the OAM’s construction is slightly different in that you now must extract and import the HTML5 Canvas animation to insert it into Dreamweaver. From the OAM files, a folder called “animation assets” is created in the root directory, which you’ll look at more closely in a moment.

After you have exported or published an OAM file from Animate, you notice that it is one single file and not separate parts. This is because the OAM is merely a package, like how you would create a ZIP file. Animate CC has put the files into one folder, and you need Dreamweaver CC to unpack it.

To do this, place your cursor either in code view or design view somewhere in a <div> or A semantic element on your webpage, and in the Insert panel’s HTML tab, click the Animated Composition icon. Refer to Figure 36-22.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig22_HTML.jpg
Figure 36-22

Use the Insert panel to unpack and insert the animated composition HTML5 canvas

If you have not saved the HTML page, Dreamweaver ask you to do so. Refer to Figure 36-23.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig23_HTML.jpg
Figure 36-23

Make sure you have saved your HTML file before you insert the animated composition

Click OK and save the HTML file in the root directory folder. At this point, select the Animated Composition dialog box. You are asked to locate the OAM file. Make sure that it is saved in your sites root directory folder. Select it and click OK. It then begins to unpack the file and insert it. The unpacked OAMs are placed on individual pages and related files are linked via the data attribute. If the OAM has already been unpacked, you may get this warning. You can click OK to override, or click Cancel and copy the generated code from another document in your site if it has been unpacked once. Refer to Figure 36-24.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig24_HTML.jpg
Figure 36-24

If the animated composition has already been unpacked you may receive this warning

The OAM then unpacks and creates code with an <object> tag. You can see an example of this on the Hot Glass Tango index.html file.
<div class="center-canvas">
      <object id="EdgeID" type="text/html" width="660" height="500" data-dw-widget="Edge" data="animation_assets/scene6_end_canvasan_HTML5_Canvas_res/Assets/ scene6_end_canvasan_HTML5_Canvas_res.html">
      </object>
    </div>
Figure 36-25 shows how it appears in the Properties panel.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig25_HTML.jpg
Figure 36-25

The unpacked animated composition contains the HTML5 Canvas file

The <object> ID tells you that it is an Edge file. As you saw in Part 4, Animate CC was once called Flash, and then it merged with Adobe Edge Animate to become Animate CC. You can add a class for a border or centering. As with the canvas, you can see the width and height and other data attributes that give a description and the link to another HTML file that contains the actual animation. The <object> is essentially acting as a linked object window to look inside another HTML page. This link is the unpackaged OAM file. All related files are found inside the animation assets folder. Refer to Figure 36-26.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig26_HTML.jpg
Figure 36-26

The unpacked animated assets as seen in the Files panel

Within the folder are:
  • XML files to control order

  • External JavaScript to control movement

  • A graphic PNG file that is a poster image

  • An HTML file that is linked to your new HTML page

  • A folder that contain the audio sounds for the canvas file

The internal structure of this file is the same as the canvas file that you saw earlier, so if your plan is to add an animation from Animate CC to a template-based page, this is a cleaner and faster option. The <object> tag acts as a “window,” and this is far better than trying to copy and paste your code from your HTML5 Canvas file directly into the template-based page. If you need to adjust your animation assets folder path, it is found in Site ➤ Manage Site in the Advanced Settings tab ➤ Animation Assets.

Inserting Flash SWF and Flash Video

I do not go into any detail regarding the steps for inserting Flash SWF (.swf) or Flash video (.flv) because most web designers are moving away from these formats due to the processing power and runtime strain it puts on mobile devices.

You can still use Dreamweaver to insert these formats if your client requests it, however. Refer to Figure 36-27.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig27_HTML.jpg
Figure 36-27

You can still use the Insert panel to insert Flash SWF and Flash video files

Note

If you are reviewing a client’s older site and you are not sure if it contains Flash SWF or Flash video files, you can check in the Assets panel in the Media tab. Refer to Figure 36-28.

../images/466782_1_En_36_Chapter/466782_1_En_36_Fig28_HTML.jpg
Figure 36-28

The Asset panel is a useful tool if you are trying to locate older flash files in a client’s root folder

You can then locate the folders that they are stored in and remove the files that are old or outdated. Media in the Assets panel does not help you locate MP4 files or audio files.

Insert Plug-in

Dreamweaver lets you add other plug-ins to your website, including RealPlayer and QuickTime movies. For more information, refer to https://helpx.adobe.com/dreamweaver/using/adding-media-objects.html . Refer to Figure 36-29.
../images/466782_1_En_36_Chapter/466782_1_En_36_Fig29_HTML.jpg
Figure 36-29

Use the plugin tag to insert third-party media

This concludes inserting various media into our HTML5 webpages by using the Insert HTML tab.

Summary

In this chapter, you looked at how to insert several types of multimedia, such as video, audio, HTML5 Canvas, and animated composition OAM. You looked at older multimedia options that Dreamweaver still offers.

In the next chapter, before you finish reviewing the site, you’ll look at a few additional options and panels that you can use in Dreamweaver to enhance the look of your site.