HTML5 multimediaBROWSER-NATIVE VIDEO AND AUDIOPatrick H. Lauke / JSDay / Verona / 17 Maggio 2012
<video>
Adobe Flash currently most common video/audio delivery mechanism
<object width="425" height="344">  <param name="movie"value="http://www.youtube.com/v/9sEI1AUFJKw&hl=en&fs=1&"></param>  <...
plug-in is a black box
<video src="video.webm"></video>           originally proposed by Opera in 2007     dev.opera.com/articles/view/labs-a-cal...
<video src="video.webm"  controls  autoplay  muted  loop  preload="none|metadata|auto"  poster="poster.jpg"  width="320" h...
video as native object
people.opera.com/patrickl/experiments/webm/hover+transition
powerful (simple) API
<video> and JavaScriptvar v = document.getElementById(player);v.play()v.pause()v.volume = …v.currentTime = …v.addEventList...
www.w3.org/2010/05/video/mediaevents.html
people.opera.com/patrickl/experiments/webm/basic-controls
HTML5 does not specifyhow browser controls should look
people.opera.com/patrickl/experiments/webm/fancy-controls
people.opera.com/patrickl/experiments/webm/fancy-swap
video formatsthe big debate?
HTML5 does not specify video container/codec (same as with images in HTML 4.01)
MP4/H.264    orOgg Theora    orWebM/VP8
MP4 / H.264ubiquitous, licensing/royalties
Ogg Theora    free and open, no licensing feesnot many tools for it, not web optimised
WebM / VP8  open and royalty-free, web-optimisedsupport by hardware and software vendors
http://tools.google.com/dlpage/webmmf
Browsers vs codecs                  Chome Firefox IE      Opera   Safari  Ogg Theora      ✔        ✔            ✔  WebM / ...
providing multiple sources<video controls width="…" height="…">  <source src="movie.mp4" type="video/mp4">  <source src="m...
specifying codecs<video controls width="…" height="…">   <source … type=video/mp4; codecs="avc1.42E01E,mp4a.40.2">   <sour...
understanding fallback<video controls width="…" height="…">   <source … type=video/mp4; codecs="avc1.42E01E,mp4a.40.2">   ...
people.opera.com/patrickl/experiments/webm/wrongsource
feature-detection for codecsv.canPlayType(video/webm;codecs="vp8,vorbis")     "probably" | "maybe" | "" < WAT?
video and Responsive Web Design<source … media="(min-width:1000px)"><source … media="(max-width:1000px)">
people.opera.com/patrickl/experiments/webm/mediaquery
people.opera.com/patrickl/experiments/webm/mediaquery
flash fallback for older browsers http://camendesign.com/code/video_for_everybody
<video controls width="…" height="…">   <source src="movie.mp4" type="video/mp4" />   <source src="movie.webm" type="video...
<audio>
audio...exactly the same as video<audio src=”music.mp3” controls autoplay … ></audio><audio controls autoplay>   <source s...
people.opera.com/patrickl/experiments/audio/windchime
no need for <audio> or <video> in your DOM   var s = document.createElement(audio);       s.src = aaargh.oga; s.play();
audio “sound sprites” to counter     latency and overhead    people.opera.com/~emoller/audio-demo
<canvas>
canvas drawing ready-made imagesctx = canvas.getContext("2d");var logo = new Image();logo.src = logo.png;ctx.drawImage(log...
canvas access to image data arrayctx = canvas.getContext("2d");canvasData = ctx.getImageData(x,y,w,h);[R,G,B,A,R,G,B,A,R,G...
canvas also works with videoctx = canvas.getContext("2d");v = document.getElementById(player);ctx.drawImage(v,x1,y1,w1,h2,...
html5doctor.com/video-canvas-magic
media.chikuyonok.ru/ambilight
is it all safe to use, right now?
www.youtube.com/html5
dont do browser sniffing      http://www.flickr.com/photos/timdorr/2096272747/
feature-detectionprogressive enhancement, graceful degradation             diveintohtml5.info/everything.html
feature-detection for audio/videoif (!!document.createElement(video).canPlayType;) { … }if (!!document.createElement(audio...
sublimevideo.net
www.jplayer.org
www.textfiles.com/underconstruction
dev.w3.org/2011/webrtc/editor/webrtc.html
dev.w3.org/2011/webrtc/editor/getusermedia.html
camera access// Operanavigator.getUserMedia({video:true},success,error);[…]video.src = stream;// WebKitnavigator.webkitGet...
www.opera.com/browser/next
neave.com/webcam/html5
shinydemos.com/qr-code
www.opera.com/developer   patrick.lauke@opera.com
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012
Upcoming SlideShare
Loading in …5
×

HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012

2,809 views

Published on

1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
2,809
On SlideShare
0
From Embeds
0
Number of Embeds
54
Actions
Shares
0
Downloads
138
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

HTML5 multimedia - browser-native video and audio - JSDay / Verona / 17 May 2012

  1. 1. HTML5 multimediaBROWSER-NATIVE VIDEO AND AUDIOPatrick H. Lauke / JSDay / Verona / 17 Maggio 2012
  2. 2. <video>
  3. 3. Adobe Flash currently most common video/audio delivery mechanism
  4. 4. <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> <embedsrc="http://www.youtube.com/v/9sEI1AUFJKw&hl=en&fs=1&" type="application/x-shockwave-flash"allowscriptaccess="always" allowfullscreen="true"width="425" height="344"></embed></object>
  5. 5. plug-in is a black box
  6. 6. <video src="video.webm"></video> originally proposed by Opera in 2007 dev.opera.com/articles/view/labs-a-call-for-video-on-the-web
  7. 7. <video src="video.webm" controls autoplay muted loop preload="none|metadata|auto" poster="poster.jpg" width="320" height="240"> <a href="video.webm">Download movie</a></video>
  8. 8. video as native object
  9. 9. people.opera.com/patrickl/experiments/webm/hover+transition
  10. 10. powerful (simple) API
  11. 11. <video> and JavaScriptvar v = document.getElementById(player);v.play()v.pause()v.volume = …v.currentTime = …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)
  12. 12. www.w3.org/2010/05/video/mediaevents.html
  13. 13. people.opera.com/patrickl/experiments/webm/basic-controls
  14. 14. HTML5 does not specifyhow browser controls should look
  15. 15. people.opera.com/patrickl/experiments/webm/fancy-controls
  16. 16. people.opera.com/patrickl/experiments/webm/fancy-swap
  17. 17. video formatsthe big debate?
  18. 18. HTML5 does not specify video container/codec (same as with images in HTML 4.01)
  19. 19. MP4/H.264 orOgg Theora orWebM/VP8
  20. 20. MP4 / H.264ubiquitous, licensing/royalties
  21. 21. Ogg Theora free and open, no licensing feesnot many tools for it, not web optimised
  22. 22. WebM / VP8 open and royalty-free, web-optimisedsupport by hardware and software vendors
  23. 23. http://tools.google.com/dlpage/webmmf
  24. 24. Browsers vs codecs Chome Firefox IE Opera Safari Ogg Theora ✔ ✔ ✔ WebM / VP8 ✔ ✔ ? ✔ MP4 / H.264 ✔ ✔ ✔mobile and devices slightly better...
  25. 25. providing multiple sources<video controls width="…" height="…"> <source src="movie.mp4" type="video/mp4"> <source src="movie.webm" type="video/webm"> <source src="movie.ogv" type="video/ogg"> <!-- fallback content --></video>
  26. 26. specifying codecs<video controls width="…" height="…"> <source … type=video/mp4; codecs="avc1.42E01E,mp4a.40.2"> <source … type=video/webm; codecs="vorbis,vp8"> <source … type=video/ogg; codecs="theora,vorbis"> <!-- fallback content --></video>
  27. 27. understanding fallback<video controls width="…" height="…"> <source … type=video/mp4; codecs="avc1.42E01E,mp4a.40.2"> <!-- fallback content → <p>Shown to browsers that dont support video element, and NOT just browsers that dont support MP4/H.264</p></video>
  28. 28. people.opera.com/patrickl/experiments/webm/wrongsource
  29. 29. feature-detection for codecsv.canPlayType(video/webm;codecs="vp8,vorbis") "probably" | "maybe" | "" < WAT?
  30. 30. video and Responsive Web Design<source … media="(min-width:1000px)"><source … media="(max-width:1000px)">
  31. 31. people.opera.com/patrickl/experiments/webm/mediaquery
  32. 32. people.opera.com/patrickl/experiments/webm/mediaquery
  33. 33. flash fallback for older browsers http://camendesign.com/code/video_for_everybody
  34. 34. <video controls width="…" height="…"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.webm" type="video/webm" /> <source src="movie.ogv" type="video/ogg" /> <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>
  35. 35. <audio>
  36. 36. 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>formats: MP3 vs Ogg Vorbis (vs WAV)
  37. 37. people.opera.com/patrickl/experiments/audio/windchime
  38. 38. no need for <audio> or <video> in your DOM var s = document.createElement(audio); s.src = aaargh.oga; s.play();
  39. 39. audio “sound sprites” to counter latency and overhead people.opera.com/~emoller/audio-demo
  40. 40. <canvas>
  41. 41. canvas drawing ready-made imagesctx = 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
  42. 42. canvas access to image data arrayctx = 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, … ]
  43. 43. canvas also works with videoctx = 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)
  44. 44. html5doctor.com/video-canvas-magic
  45. 45. media.chikuyonok.ru/ambilight
  46. 46. is it all safe to use, right now?
  47. 47. www.youtube.com/html5
  48. 48. dont do browser sniffing http://www.flickr.com/photos/timdorr/2096272747/
  49. 49. feature-detectionprogressive enhancement, graceful degradation diveintohtml5.info/everything.html
  50. 50. feature-detection for audio/videoif (!!document.createElement(video).canPlayType;) { … }if (!!document.createElement(audio).canPlayType;) { … }
  51. 51. sublimevideo.net
  52. 52. www.jplayer.org
  53. 53. www.textfiles.com/underconstruction
  54. 54. dev.w3.org/2011/webrtc/editor/webrtc.html
  55. 55. dev.w3.org/2011/webrtc/editor/getusermedia.html
  56. 56. camera access// Operanavigator.getUserMedia({video:true},success,error);[…]video.src = stream;// WebKitnavigator.webkitGetUserMedia("video",success,error);[…]video.src = window.webkitURL.createObjectURL(stream); gUM Shield: http://html5doctor.com/getusermedia/
  57. 57. www.opera.com/browser/next
  58. 58. neave.com/webcam/html5
  59. 59. shinydemos.com/qr-code
  60. 60. www.opera.com/developer patrick.lauke@opera.com

×