This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Multimedia


Three main types of multimedia exist on the web images, audio, and video. HTML5 has three tags to include, or embed, these elements into a web page:

  • <img>
  • <audio>
  • <video>

Images

The image tag <img> has one required attribute and several optional attributes. The image tag requires an image source attribute to be present. It is also important that images also provide alternate text so that all users can be aware of the image content.

<img src="http://example.com/image.webp" alt="Example image." />

Images can be given additional attributes including width, height, and a couple of attributes relating to image maps (images with specific interactive areas).

Open image formats include PNG, JPEG, and WebP.

The GIMP is a free photo manipulation tool that you can use to create and edit images for your web pages and even create web layouts. Inkscape is a vector graphics (i.e. SVG) illustrator that can be used to create images, web pages, layouts, and other vector based projects.

Audio

The <audio> tag is new  in HTML5. It gives designers a standard way to include audio in a page. The <audio> tag has several parameters the most important of which is source:

<audio src="file.ogg">Text for browsers that do not support the audio tag.</audio>

Other  attributes for the <audio> tag include autoplay, controls, loop, and preload.

Ogg Vorbis is an open format for web audio and is supported by Mozilla Firefox, Google Chrome, and Opera.

Several free tools exist with support for Ogg Vorbis audio:

Video

The <video> tag is also new in HTML5. We can now insert video into a web page without the need for third party plugins! The source attribute is key to the video tag:

<video src="video.ogv">Text for browsers without support for the video tag.</video>

Additional attributes for the <video> tag include audio, autoplay, controls, height, loop, poster, preload, and width.

Ogg Theora and WebM are open formats for Internet video both of which work on Mozilla Firefox, Google Chrome, Chromium, Konqueror, and Opera. Several free tools exist to convert new and existing video to Ogg Theora and/or WebM including:

It is possible to offer alternative formats for browsers that do not support Ogg Theora or WebM. To do this, you nest multiple <source> tags within a <video> tag as such:

<video>
  <source src="file.ogv" type="video/ogg" />
  <source src="file.webm" type="video/webm" />
  <source src="file.mp4" type="video/mp4" />
  Text or markup to display if the video does not play.
</video>

There are also several video hosting/streaming communities that support open formats:

Further information:

Diskutera uppgift


  • EcologicalHumanist   10 juli 2013 17:27

    https://ecohumanist.makes.org/thimble/image-audio-video

  • EcologicalHumanist   10 juli 2013 17:26

    It seems like it isn't enough to put the source, you have to add:

    preload="preload" controls="control"

    to the audio and video tag.  Other than that no problems.

  • bryanwoodsmall   2 juli 2013 00:10

    Finally got a simple example of video, image, and audio to work.

    It turned out that I needed codecs with the video.  I'm not sure why.  It seemed like other people did not need them.  I found tham on html5rocks (http://www.html5rocks.com/en/tutorials/video/basics/)

     

    For the image, I was using a photo which was a large jpeg.  I had to reduce its size to make it work.

    The audio worked with no problems.

    Here is the link to my work: http://makefriendswithalgebra.com/videoaudio.html

  • Deiren   27 januari 2013 13:59

    Simply testing - https://thimble.webmaker.org/p/fuew

  • Gerardo Muñoz Asca   23 januari 2013 20:04
  • Joris Pekel   10 oktober 2012 08:46

    Does not work well in Wordpress Posted it to the HTML Pad

  • saravanan   16 augusti 2012 09:48

    Really tough to complete.

    Moraino page helped me.

    I tried it check out.

    http://htmlpad.org/mult2453/

  • al read   16 augusti 2012 09:50
    Som Svar På:   saravanan   16 augusti 2012 09:48
    Thanks for your message. I will be out of the office on annual leave until Monday 20th August If your enquiry is urgent, please SMS me on my mobile. Kind regards, Alan Read Head of Learning Technologies Learning Technologies Group Pearson UK +44 (0) 7703 750913 This email was sent by a company owned by Pearson plc, registered office at 80 Strand, London WC2R 0RL. Registered in England and Wales with company number 53723
  • hamilton mena quejada   24 juni 2012 22:07
  • Giorgos Dimop   31 maj 2012 13:21

    http://htmlpad.org/multimedia-gd/

     

    I couldn't make the audio work.

    I also found that <video controls="controls"> is needed to add playback buttons and timeline.

  • Nick   6 maj 2012 08:50

    I'm starting to realize not everything is given to us in order to complete the challenge laugh  Anyways... here is my multimedia page.  BTW i've only been making sure my ass. work with chrome so far

  • Pau Company   4 april 2012 12:11

    El problema que veo en la utilización de la etiqueta video, es que para cada navegador, necesitamos un formato de video diferente, con lo que esto aumenta considerablemente ya no el trabajo de convertir los videos a mp4, ogg o webm, si no que los hosting de nuestros servidores, se van a llenar de el mismo video, pero con extensiones diferentes, con lo cual, el peso de este va a aumentar considerablemente.

     

    <video>
                  <source src="demo/videos/tabarca.mp4" type='video/mp4; codecs="avc1,mp4"' /> <!-- Chrome -->
    <source src="demo/videos/Tabarca_xo.ogg" type='video/ogg; codecs="theora,vorbis"'  /> <!-- Firefox 5,6,7,8 -->
    <source src="demo/videos/Tabarca.webmvp8.webm"  type='video/webm ; codecs="vp8,vorbis"' /><br/> <!-- IE 8, 9 -->
    </video>

     

    Os pongo un ejemplo, que he realizado, con un reproductor, personalizado, que soporta pantalla completa. Decir que el codigo JavaScript y el reproductor es de la empresa github.com, lo utilizo ya que es de facil implementación. Utiliza, ajax y jquery, asi como polyfilles en javascript. Darle las gracias a github.com, por liberar el codigo y hacernos la vida mas facil. Aqui va todo el codigo y el link a mi servidor para que veais el resultado

     

     

    <!DOCTYPE html>
    <html lang="es">
        <head>
            <meta charset="utf-8"/>
            <link href="player-style/css/player-styles.css" rel="stylesheet" />
    <!--[if lt IE 9]>
    <script src="http://HTML5shim.googlecode.com/svn/trunk/HTML5.js">
    </script>
    <![endif]-->
     
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
            <!-- only slider + dependencies are required -->
            <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
    <!-- END: slider -->
     
            <!-- polyfill: only needed if you want to make it cross browser -->
            <script src="http://afarkas.github.com/webshim/demos/js-webshim/minified/extras/modernizr-custom.js"></script>
            <script src="http://afarkas.github.com/webshim/demos/js-webshim/minified/polyfiller.js"></script>
    <!-- END: polyfill -->
     
            <script src="../src/jme.js"></script>
    <!-- start polyfill (only if webshims is included) -->
            <script>
                $.webshims.polyfill('mediaelement');
            </script>
            <title>jme2</title>
        </head>
        <body>
        <div class="mediaplayer" preload="none" data-jme='{"controlbar": true}'>
    <video>
     
       <!-- aqui donde pone micarpeta/miarchivo.mp4 debereis poner el nombre de la carpeta donde se ubican vuestros videos y en¡l nombre del video en si -->
     
                  <source src="micarpeta/miarchivo.mp4" type='video/mp4; codecs="avc1,mp4"' /> <!-- Chrome -->
     
    <source src="micarpeta/miarchivo.ogg" type='video/ogg; codecs="theora,vorbis"'  /> <!-- Firefox 5,6,7,8 -->
    <source src="micarpeta/miarchivo.webmvp8.webm"  type='video/webm ; codecs="vp8,vorbis"' /><br/> <!-- IE 8, 9 -->
    </video>
    </div>
    </body>
    </html>
     
     
    El Link donde podeis visualizar el resultado es:

     

    Si necesitais alguna ayuda, podeis contactar conmigo en info@paucompany.es

     

    Y aqui teneis el ejercicio entero acabado. Añado una pequeña mejora el 30/05/2012 al audio, una lista de reproducción, para escuchar mas de una canción. Utilizo Javascript. 

    http://paucompany.es/ejercicioshtml5/html5ejrecicio3.html

    Espero comentarios.

  • Mr. Plow   22 mars 2012 12:18

    This was a fun one to complete!

    I present Seeds and Pops and Spins.

  • Devinciweb   10 februari 2012 14:09

    Here is my work for this task:

     

    http://dl.dropbox.com/u/60089935/multimediatask.html

  • Devinciweb   10 februari 2012 13:36

    For me in this code here the text shows even with the video playing

    <!--
    <video>
      <source src="file.ogv" type="video/ogg" />
      <source src="file.webm" type="video/webm" />
      <source src="file.mp4" type="video/mp4" />
      Text or markup to display if the video does not play.
    </video>
    -->
    

  • Moraino   17 januari 2012 07:19

    That was a little bit tough, but  here it is:

    http://htmlpad.org/Multimedia/

  • José González   26 januari 2012 10:41
    Som Svar På:   Moraino   17 januari 2012 07:19

     

    Hi to all. I did the same test over my first page.
     
    http://htmlpad.org/kikofreakk
     
    But I can't run the audio or video tags in Explorer versions under 9.x (P.E. Internet Explorer 8). Do you know any way to run in all of the browsers (at least in the generalists).
     
    Greetings, FreaKK
  • Vita   26 januari 2012 13:33
    Som Svar På:   José González   26 januari 2012 10:41

    Hello José,

    the  problem with your could be the single type of audio and video. There are two different types of audio files that you can add in your HTML code ( .ogg / .mp3 ) I suggest you to put both of them because IE doesn't support .ogg files, but it supports .mp3 files, so that means you need to add both of them. Ogg is for the webkit browsers and mp3 for IE. You can do it like this:

    <audio controls="controls">

    <source src="file/example.ogg" type="audio/ogg">

    <source src="file/example.mp3" type="audio/mpeg">

    TU NAVEGADOR NO SOPORTA HTML5 - Estarías escuchando La Marcha Granadera, el actual Himno de España

    </audio>

    So that means that you need to have both types of files and if you put them both in your code the browser will be able to recognise the file it supports.

    The same thing is with video, only difference is that you have to put three types of files ( .ogv / mp4 /  .webm):

    <video controls="controls">

    <source src="file/example.ogv" type="video/ogg">

    <source src="file/example.mp4" type="video/mp4">

    <source src="file/example.webm" type="video/webm">

    TU NAVEGADOR NO SOPORTA VIDEO OGG - Estarías viendo como se unen 2 cables con una fuente de calor

    </video>

    Try it, I hope it will help...

    Vita

  • Vita   21 november 2011 06:30

    Ok, finaly did it... <video> and <audio> tags always seem so simple... but then when u get to work.... well... let's just say - takes more time than expected...

    Anyway, here's what I did :

    http://dl.dropbox.com/u/18761433/HTML5Course/multimedia.html

  • Devinciweb   6 februari 2012 10:25
    Som Svar På:   Vita   21 november 2011 06:30

    I love the way you set up your exercises all on one dropbox page.

    Nice and inspiring!

  • Vita   6 februari 2012 12:23
    Som Svar På:   Devinciweb   6 februari 2012 10:25

    Thank you! 

    It's always nice to see that your work is appreciated... smiley

  • Kommentaren togs bort.
  • joe palmer   17 november 2011 09:48
    Som Svar På:   Anonym   17 november 2011 00:02

    I think it is your doctype, change it to the HTML5 doctype- 

    <!DOCTYPE html>

    also see what Alcinoe did holding cntrl than hit u key...

    In class all day, wish I could help more, anyone else?

  • Anonym   17 november 2011 10:54
    Som Svar På:   joe palmer   17 november 2011 09:48

    I changed the doctype to fit html5 and cleaned up meta section.  I was watching one of Stanford Uni's videos, and in it the speaker said all the junk I had in <!DOCTYPE html>  was now outdated. I also copied Alcinoe's code for audio, but all to no avail.  I don't understand the ' holding cntrl than hit u key' bit.  U as in letter u?  

  • joe palmer   17 november 2011 11:15
    Som Svar På:   Anonym   17 november 2011 10:54

    Yes on the u, I should have probably said go to view source but the new Firefox does not have that in the toolbar anymore and that is how you view source now in Firefox, hold cntrl hit u and the view source window pops out. Inbetween classes, sorry can't do more, was curious to this also, I bet if  you view source on some of these others you will see what needs a tweek, but you must have or you would not have seen Alcinoes. Oh, what browser do you use? Try another, than you may have to find what they put in to support the browser that you do use, IE is famous for having to add extra things into the code to get what Chrome or Firefox do on thier own.

    I put your view source next to one that works and can't figure it yet, but your tag for charset = "utf-8" should not have a / end hash in it, it is always soemthing real little thing that throws things off...recheck your audio source?

    Anybody????

  • Anonym   17 november 2011 18:06
    Som Svar På:   joe palmer   17 november 2011 11:15

    I ran my file through the online markup validation service.  It didn't complain about the / after utf-8 or any part of the audio coding.  It doesn't like the comment before <!DOCTYPE>.  The only complaint it had was about the stray end tag for </embed>, which doesn't make any sense to me.

    I use FireFox.  I've looked at the source code of all posters a few days ago.  Some of them have the same problem as I.  I'll look at each one more carefully.

  • joe palmer   17 november 2011 18:47
    Som Svar På:   Anonym   17 november 2011 18:06

    Your audio works for me now, it sounds Yiddish or something, a man not speaking in English. What version FF do you have? Lets just say it has to be at least version 3.5, but they are all the way up to versoin 8 now, so maybe you should go to the Firefox website and download the latest version, your bookmarks and all will remain. I bet that is what it is, let me know.

  • Anonym   17 november 2011 21:57
    Som Svar På:   joe palmer   17 november 2011 18:47

    I upgraded FF to 8, but the problem hasn't gone away.  I looked at my page in IE on my friend's laptop.  Image and YouTube video work.  The console bar for the first audio is in the middle of the audio window, but it works.  For the second audio bit, there is no gray box or console.  It displays the message "Your browser is not supported," or something similar.

  • joe palmer   17 november 2011 22:30
    Som Svar På:   Anonym   17 november 2011 21:57

    http://www.devx.com/projectcool/Article/20131/0/page/3

    Thats good, it is late here but the other question, those are special charaters that need to be wrote differantly,

    Sleep time here, have fun. Remeber Google is your friend.

  • alcinoe   17 november 2011 23:35
    Som Svar På:   Anonym   17 november 2011 00:02

     

    I think that you need to look at the audio files themselves. They must be named jer1.ogg and jer1.mp3. in order for them to work. Also, if your original file was mp3, you need to use a converter to make it into a ogg file (and vice versa). 
     
    I think that your ogg file is named jer1.ogg.ogv. That would actually make it look like a video file, and because it is not named properly, it can't be found. I think that this is why it is not playing in Firefox. It is fine in Chrome because Chrome looks for and finds the correctly named mp3 file. Firefox does not support mp3 so it looks for and can't find the ogg file.
  • Anonym   18 november 2011 11:11
    Som Svar På:   joe palmer   17 november 2011 22:30

    Thank you for the link.  Today I don't have much computer time until the evening, but I'll definitly look at the link you gave me. 

    Yes, Google has been my best friend.  I'm still learning to be a good google-searcher.

  • Anonym   18 november 2011 11:26
    Som Svar På:   alcinoe   17 november 2011 23:35

    I did convert my mp3 to ogg, and it has the extension .ogg, not .ogg.ogv as far as I can see...  Ah, I didn't know that Firefox does not support playback of mp3 files in <audio> elements,  Thanks for the info.  FF supports ogg, so it should play jer1.ogg, shouldn't it?  

  • joe palmer   18 november 2011 12:19
    Som Svar På:   Anonym   18 november 2011 11:11

    I think Alcinoe figured out the problem. Here is another site to see stuff, and I Google tags themselves with HTML5 on them (embed tag HTML5), I might catch bad for this but I do steer clear of W3C school, they have nothing to do with the real W3C. You'll know good sources when you see them, the trick for me is balancing learning with doing, what good is the reading if I'm not making something. There are good ideas in here too fish out and see, tons...

    http://html5gallery.com/

    This is a great resource, but there are more like boiler plate too...

    http://www.webmonkey.com/2010/02/building_web_pages_with_html_5/

    This is the real W3C,I go look up a tag there sometimes but it can get heady, not the best place for a novice, but serious students should know it is there.

    http://www.w3.org/

    Have fun!

  • alcinoe   18 november 2011 12:42
    Som Svar På:   Anonym   18 november 2011 11:26

    Ok, I think that i got it now. Your ogg file uses the flac codex and it is not supported by firefox. It must use either the Vorbis or Theora Codex.

    http://forums.mozillazine.org/viewtopic.php?f=7&t=2268617

  • alcinoe   18 november 2011 13:09
    Som Svar På:   Anonym   17 november 2011 00:02

    I put both your original file, and a file with the changed codex at the bottom of this page:

    http://www.alcinoe.us/HTML5/Multimedia.html

    The one that I changed works in firefox, and the other one does not.

    If you want to save the file, right click and hit "save audio as"  It iwill add an ogv to the end of the file - this needs to be removed. I also renamed it to jer2.ogg so you either have to change the file name or change it in your code.

  • Anonym   18 november 2011 17:52
    Som Svar På:   alcinoe   18 november 2011 13:09

    I saved jer2.ogg as you said, ie., right click and hit 'save sudio as,' but it doesn't have .ogg.ogv extension.  I'm not sure if I'm understanding you correctly...

  • Anonym   18 november 2011 17:59
    Som Svar På:   alcinoe   18 november 2011 12:42

    Oh Thanks!  I just saw this message from you.

  • Anonym   18 november 2011 18:21
    Som Svar På:   alcinoe   18 november 2011 12:42

    Thanks much!  That was the problem.  When I converted mp3 to ogg, I used an online converter.  It didn't show any details (as far as I could see) about the codex.  I just installed mp32ogg-vorbis converter and converted my mp3.  My page works now.  Thanks again.

  • Anonym   18 november 2011 18:49
    Som Svar På:   joe palmer   18 november 2011 12:19

    Sure she did!  Thank you though for your trying to help me and for the useful links.

  • joe palmer   18 november 2011 19:01
    Som Svar På:   Anonym   18 november 2011 18:49

    The best part is I learned new stuff tooenlightened !

  • Anonym   18 november 2011 19:12
    Som Svar På:   joe palmer   17 november 2011 22:30

    Thank you for the link to David Colhoun's page.  I think his homepage is very clean and simple.  I like it a lot yes

  • alcinoe   18 november 2011 19:36
    Som Svar På:   Anonym   18 november 2011 17:52

    The original file, when I downloaded it from firefox, renamed itself with an ogg.ogv (crazy) extension - that's why I thought that it wasn't named properly at first. Now it is downloading properly as .ogg. 

  • Anonym   18 november 2011 19:42
    Som Svar På:   alcinoe   18 november 2011 19:36

    I wanted to ask you how you thought it was the codex, but you answered my question before I got to ask.  Thank you for sharing your thought process.

  • alcinoe   18 november 2011 19:47
    Som Svar På:   Anonym   18 november 2011 18:21

    You're welcome Demian!

  • Anonym   16 november 2011 04:37

    RE: THE <audio> TAG - controls="controls" 

    The audio console appears just for a second and it disappears, and I'm left with a grey box with 'X' in it.  Could someone tell me what may be the problem and how to fix it?  Thanks.

  • Anonym   16 november 2011 04:05

    For audio, do I need to convert mp3 to ogg in order for the audio tag to work?  That seems like a bad thing to do, because converting from one lossy format (mp3) to another (ogg) will degrade the sound quality.  Are there any other ways to add mp3 to my web?

  • Anonym   16 november 2011 04:59
    Som Svar På:   Anonym   16 november 2011 04:05

    This doesn't look pretty but works (at least on my browser - firefox). 

    <embed src="jer1.mp3" autostart="false" volume="100">
    </embed>

  • alcinoe   16 november 2011 10:10
    Som Svar På:   Anonym   16 november 2011 04:05

    You should include both mp3 and ogg so that it works in as many browsers as possible.

  • Anonym   16 november 2011 15:34
    Som Svar På:   alcinoe   16 november 2011 10:10

    I did.

    Using the <audio> tag, I can't get the console.  It appears for about one second and then disappears.  Do you know how to fix it?

  • joe palmer   16 november 2011 16:34
    Som Svar På:   Anonym   16 november 2011 15:34

    Paste your dropbox link on or something so people can see what you have :)