SlideShare a Scribd company logo
audio, video and canvas in HTML5
NATIVE MULTIMEDIA SUPPORT




Patrick H. Lauke / standards>next / Manchester / 29 September 2010
HTML5
<!DOCTYPE html>
“...extending the language to better
support Web applications [...] This puts
HTML in direct competition with other
technologies[...] , in particular Flash and
Silverlight.”
Ian Hickson, Editor of HTML5
http://lists.w3.org/Archives/Public/public-html/2009Jan/0215.html
making your site Fonzie compliant...
<video>
Adobe Flash currently most common
    video delivery mechanism
<object width="425" height="344">
  <param name="movie"
value="http://www.youtube.com/v/9sEI1AUFJKw&hl=en
&fs=1&"></param>
  <param name="allowFullScreen"
value="true"></param>
  <param name="allowscriptaccess"
value="always"></param>
  <embed
src="http://www.youtube.com/v/9sEI1AUFJKw&hl=en&f
s=1&" type="application/x-shockwave-flash"
allowscriptaccess="always" allowfullscreen="true"
width="425" height="344"></embed>
</object>
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
<video src="video.webm"
  controls
  Autoplay
  Loop
  preload="none"
  poster="poster.jpg"
  width="320" height="240">
    <a href="video.webm">Download movie</a>
</video>
video as native object
● “plays nice” with rest of the page
●
  keyboard accessibility built-in
video formats
   the big debate
MP4 / H.264




ubiquitous, patent encumbered, licensing/royalties
Ogg Theora




“free and open”, no licensing/royalties
not many tools for it, not web optimised
www.webmproject.org
WebM




open and royalty-free, web optimised
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
www.youtube.com/html5
providing multiple sources
<video controls autoplay poster="…" width="…" height="…">
   <source src="movie.webm" type="video/webm" />
   <source src="movie.ogv" type="video/ogg" />
   <source src="movie.mp4" type="video/mp4" />
   <!-- fallback content -->
</video>
still include fallback for old browsers
     http://camendesign.com/code/video_for_everybody
<video controls autoplay poster="…" width="…" height="…">
   <source src="movie.webm" type="video/webm" />
   <source src="movie.ogv" type="video/ogg" />
   <source src="movie.mp4" type="video/mp4" />

   <object width="…" height="…" type="application/x-
shockwave-flash" data="player.swf">
      <param name="movie" value="player.swf" />
      <param name="flashvars" value=" … file=movie.mp4" />
      <!-- fallback content -->
   </object>

</video>
powerful (simple) API
    to script your own controls
icant.co.uk/easy-youtube
www.w3.org/TR/html5/video.html#media-elements
controlling a <video> element
var v = document.getElementById('player');

v.play();
v.pause();
v.volume = … ;
v.currentTime = … ;
…
events fired by <video> element
var v = document.getElementById('player');

v.addEventListener('loadeddata', function() { … }, true)
v.addEventListener('play', function() { … }, true)
v.addEventListener('pause', function() { … }, true)
v.addEventListener('timeupdate', function() { … }, true)
v.addEventListener('ended', function() { … }, true)
…
<audio>
audio exactly the same as video
<audio src=”music.mp3” controls autoplay></audio>

[...]

<audio controls autoplay>
   <source src="music.mp3" type="audio/mpeg" />
   <source src="music.oga" type="audio/ogg" />
   <!-- fallback content -->
</audio>

same format debacle: MP3 vs Ogg Vorbis (vs WAV)
<canvas>
canvas = “scriptable images”

<canvas width="…" height="…"></canvas>
canvas has standard API methods for drawing
ctx = canvas.getContext("2d");
ctx.fillRect(x, y, width, height);
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x, y);
ctx.bezierCurveTo(x1, y1, x2, y2, c1, c2);
canvas drawing ready-made images
ctx = canvas.getContext("2d");

var logo = new Image();
logo.src = 'logo.png';

ctx.drawImage(logo,x1,y1,w1,h1,x2,y2,w2,h2);

or call in an existing image already on the page
canvas access to image data array
ctx = canvas.getContext("2d");
canvasData = ctx.getImageData(x,y,w,h);

[R,G,B,A,R,G,B,A,R,G,B,A,R,G,B,A, … ]
canvas exporting image data as data:uri
ctx = canvas.getContext("2d");
…
canvas.toDataURL("image/png");
// returns "data:image/png;base64,…"

canvas.toDataURL("image/jpg");
// returns "data:image/jpeg;base64,…"



Note: do it on the canvas, not the context!
canvas also works with video
ctx = canvas.getContext("2d");
v = document.getElementById('player');

ctx.drawImage(v,x1,y1,w1,h2,x2,y2,w2,h2);

grab currently displayed frame (update as appropriate)
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
canvas accessibility concerns
video, audio and canvas on any device
           without plugins
         (Java / Flash / Silverlight not ubiquitous)
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
HTML5 (and friends) has
lots more APIs for developers
       (for powerful client-side apps)
isgeolocationpartofhtml5.com
geolocation
navigator.geolocation.getCurrentPosition(success, error);
navigator.geolocation.watchCurrentPosition(success, error);

function success(position) {
   /* where's Wally? */
   var lat = position.coords.latitude;
   var long = position.coords.longitude;
   ...
}
offline detection...
window.addEventListener('online', function(){ … }, true);
window.addEventListener('offline', function(){ … }, true);


               and application cache
<html manifest=”blah.manifest”>

CACHE MANIFEST
# send this with correct text/cache-manifest MIME
images/sprites.png
scripts/common.js
scripts/jquery.js
styles/global.css
data.xml


                  and many more...
                       (even beyond HTML5)
is it all safe to use, right now?
don't do browser sniffing



      http://www.flickr.com/photos/timdorr/2096272747/
audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010
feature-detection
progressive enhancement, graceful degradation – or use shims
                   http://diveintohtml5.org/everything.html
feature-detection for audio/video
if (!!document.createElement('video').canPlayType;) { … }

if (!!document.createElement('audio').canPlayType;) { … }
feature-detection for audio/video codecs
var v = document.createElement('video');
if (!!(v.canPlayType)&&
     ((v.canPlayType('video/webm;codecs="vp8,vorbis"') == 'probably')
      ||
      (v.canPlayType('video/webm;codecs="vp8, vorbis"') == 'maybe')))
{ … }
ready-made HTML5 audio/video players
           (for the lazy)
sublimevideo.net
videojs.com
www.happyworm.com/jquery/jplayer
HTML5 as Flashkiller?
not a question of HTML5 replacing Flash...
giving developers a choice!
www.opera.com/developer
people.opera.com/patrickl/presentations/standards-next_29.09.2010/standards-next_29.09.2010.pdf
                             patrick.lauke@opera.com

More Related Content

PDF
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05...
PDF
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
PDF
HTML5 multimedia - browser-native video, audio and canvas - meet.js Summit / ...
PDF
HTML5 multimedia - browser-native video and audio - DevUp HTML5 / Barcelona /...
KEY
Video.js - How to build and HTML5 Video Player
PDF
HTML5 multimedia - where we are, where we're going
PDF
Making the HTML5 Video element interactive
KEY
Web Apps
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05...
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
HTML5 multimedia - browser-native video, audio and canvas - meet.js Summit / ...
HTML5 multimedia - browser-native video and audio - DevUp HTML5 / Barcelona /...
Video.js - How to build and HTML5 Video Player
HTML5 multimedia - where we are, where we're going
Making the HTML5 Video element interactive
Web Apps

What's hot (20)

PDF
HTML5 APIs - The New Frontier
PDF
HTML5 Multimedia Accessibility
PDF
HTML5 Multimedia: where we are, where we're going
PDF
Taking HTML5 video a step further
PDF
Hero Video Performance
KEY
HTML5 Video Player - HTML5 Dev Conf 2012
PDF
[rwdsummit] Adaptive Images in Responsive Web Design
PDF
[parisweb] Adaptive Images in Responsive Web Design
PDF
[convergese] Adaptive Images in Responsive Web Design
PDF
[peachpit] Adaptive Images in Responsive Web Design
PDF
[CSSDevConf] Adaptive Images in Responsive Web Design 2014
PDF
[funka] Adaptive Images in Responsive Web Design
PPTX
Html5 Game Development with Canvas
PDF
Mobile Web Video
PDF
High Performance Images
PDF
[wvbcn] Adaptive Images in Responsive Web Design
PDF
[cssdevconf] Adaptive Images in Responsive Web Design
PDF
[Austin WordPress Meetup] Adaptive Images in Responsive Web Design
PDF
[wcatx] Adaptive Images in Responsive Web Design
KEY
HTML5와 모바일
HTML5 APIs - The New Frontier
HTML5 Multimedia Accessibility
HTML5 Multimedia: where we are, where we're going
Taking HTML5 video a step further
Hero Video Performance
HTML5 Video Player - HTML5 Dev Conf 2012
[rwdsummit] Adaptive Images in Responsive Web Design
[parisweb] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
[peachpit] Adaptive Images in Responsive Web Design
[CSSDevConf] Adaptive Images in Responsive Web Design 2014
[funka] Adaptive Images in Responsive Web Design
Html5 Game Development with Canvas
Mobile Web Video
High Performance Images
[wvbcn] Adaptive Images in Responsive Web Design
[cssdevconf] Adaptive Images in Responsive Web Design
[Austin WordPress Meetup] Adaptive Images in Responsive Web Design
[wcatx] Adaptive Images in Responsive Web Design
HTML5와 모바일
Ad

Viewers also liked (6)

PPTX
HTML5 Canvas
PPTX
Academy PRO: HTML5 Data storage
ODP
Indexed db
PPT
HTML5 Canvas
PPTX
Getting Started with HTML5 in Tech Com (STC 2012)
PDF
HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas
Academy PRO: HTML5 Data storage
Indexed db
HTML5 Canvas
Getting Started with HTML5 in Tech Com (STC 2012)
HTML5 Canvas - The Future of Graphics on the Web
Ad

Similar to audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010 (20)

PDF
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
PDF
Brave new world of HTML5
PDF
webinale2011_Chris Mills_Brave new world of HTML5Html5
PDF
Web Directions @media 2010
PPTX
DoctypeHTML5 (Hyderabad) Presentation on Multimedia
PDF
JS Days HTML5 Flash and the Battle for Faster Cat Videos
PDF
Multimedia on the web - HTML5 video and audio
PDF
HTML5 and friends - JISC CETIS Conference 2010 Nottingham 15.11.2010
PDF
GDD HTML5, Flash, and the Battle for Faster Cat Videos
PDF
HTML5 and friends - standards>next Manchester 24.11.2010
PDF
Brave new world of HTML5 - WebTech 2010 Milano 09.11.2010
PDF
HTML5: A primer on the web's present and future
PPTX
HTML5 for Rich User Experience
PDF
WordCamp Thessaloniki2011 The NextWeb
PDF
HTML5, Flash, and the Battle For Faster Cat Videos
PDF
Browsers with Wings
PDF
Word camp nextweb
PPTX
DevChatt: The Wonderful World Of Html5
PDF
Speak the Web 15.02.2010
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
Brave new world of HTML5
webinale2011_Chris Mills_Brave new world of HTML5Html5
Web Directions @media 2010
DoctypeHTML5 (Hyderabad) Presentation on Multimedia
JS Days HTML5 Flash and the Battle for Faster Cat Videos
Multimedia on the web - HTML5 video and audio
HTML5 and friends - JISC CETIS Conference 2010 Nottingham 15.11.2010
GDD HTML5, Flash, and the Battle for Faster Cat Videos
HTML5 and friends - standards>next Manchester 24.11.2010
Brave new world of HTML5 - WebTech 2010 Milano 09.11.2010
HTML5: A primer on the web's present and future
HTML5 for Rich User Experience
WordCamp Thessaloniki2011 The NextWeb
HTML5, Flash, and the Battle For Faster Cat Videos
Browsers with Wings
Word camp nextweb
DevChatt: The Wonderful World Of Html5
Speak the Web 15.02.2010

More from Patrick Lauke (20)

PDF
These (still) aren't the SCs you're looking for ... (mis)adventures in WCAG 2...
PDF
Pointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
PDF
These aren't the SCs you're looking for ... (mis)adventures in WCAG 2.x inter...
PDF
These aren't the SCs you're looking for ... (mis)adventures in WCAG 2.x inter...
PDF
Too much accessibility - good intentions, badly implemented / Public Sector F...
PDF
Styling Your Web Pages with Cascading Style Sheets / EDU course / University ...
PDF
Evaluating web sites for accessibility with Firefox / Manchester Digital Acce...
PDF
Managing and educating content editors - experiences and ideas from the trenc...
PDF
Implementing Web Standards across the institution: trials and tribulations of...
PDF
Geolinking content - experiments in connecting virtual and physical places / ...
PDF
All change for WCAG 2.0 - what you need to know about the new accessibility g...
PDF
Web Accessibility - an introduction / Salford Business School briefing / Univ...
PDF
Doing it in style - creating beautiful sites, the web standards way / WebDD /...
PDF
Web standards pragmatism - from validation to the real world / Web Developers...
PDF
Ian Lloyd/Patrick H. Lauke: Accessified - practical accessibility fixes any w...
PDF
The state of the web - www.salford.ac.uk / 2007
PDF
Keyboard accessibility - just because I don't use a mouse doesn't mean I'm se...
PDF
WAI-ARIA An introduction to Accessible Rich Internet Applications / JavaScrip...
PDF
WAI-ARIA An introduction to Accessible Rich Internet Applications / CSS Minsk...
PDF
WAI-ARIA An introduction to Accessible Rich Internet Applications / AccessU 2018
These (still) aren't the SCs you're looking for ... (mis)adventures in WCAG 2...
Pointer Events Working Group update / TPAC 2023 / Patrick H. Lauke
These aren't the SCs you're looking for ... (mis)adventures in WCAG 2.x inter...
These aren't the SCs you're looking for ... (mis)adventures in WCAG 2.x inter...
Too much accessibility - good intentions, badly implemented / Public Sector F...
Styling Your Web Pages with Cascading Style Sheets / EDU course / University ...
Evaluating web sites for accessibility with Firefox / Manchester Digital Acce...
Managing and educating content editors - experiences and ideas from the trenc...
Implementing Web Standards across the institution: trials and tribulations of...
Geolinking content - experiments in connecting virtual and physical places / ...
All change for WCAG 2.0 - what you need to know about the new accessibility g...
Web Accessibility - an introduction / Salford Business School briefing / Univ...
Doing it in style - creating beautiful sites, the web standards way / WebDD /...
Web standards pragmatism - from validation to the real world / Web Developers...
Ian Lloyd/Patrick H. Lauke: Accessified - practical accessibility fixes any w...
The state of the web - www.salford.ac.uk / 2007
Keyboard accessibility - just because I don't use a mouse doesn't mean I'm se...
WAI-ARIA An introduction to Accessible Rich Internet Applications / JavaScrip...
WAI-ARIA An introduction to Accessible Rich Internet Applications / CSS Minsk...
WAI-ARIA An introduction to Accessible Rich Internet Applications / AccessU 2018

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Tartificialntelligence_presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation theory and applications.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
August Patch Tuesday
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Tartificialntelligence_presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Assigned Numbers - 2025 - Bluetooth® Document
gpt5_lecture_notes_comprehensive_20250812015547.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Getting Started with Data Integration: FME Form 101
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Zenith AI: Advanced Artificial Intelligence
Web App vs Mobile App What Should You Build First.pdf
Unlocking AI with Model Context Protocol (MCP)
SOPHOS-XG Firewall Administrator PPT.pptx
Programs and apps: productivity, graphics, security and other tools
Encapsulation theory and applications.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
August Patch Tuesday
1 - Historical Antecedents, Social Consideration.pdf
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx

audio, video and canvas in HTML5 - standards>next Manchester 29.09.2010