SlideShare a Scribd company logo
HTML5 vs. Flash
Where Flash isn’t needed anymore
Remy Sharp
@rem
Sometimes does
flash-ing
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
1. video & Audio
2. Real-time
3. Graphics
Video killed the
radio Flash star?
HTML5: where flash isn't needed anymore
Who would jump to create
 another video player?
IE9 & all others
   supported
<video src="dizzy.mp4"></video>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset=utf-8 />
  <title>Video Example</title>
</head>
<body>
<video src="dizzy.mp4" controls></video>
</body>
</html>
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
<video src="dizzy.mp4" controls></video>
<video controls>
  <source type="video/mp4" src="dizzy.mp4" codecs="avc1.42E01E, mp4a.40.2">
  <source type="video/webm" src="dizzy.webm" codecs="vp8, vorbis">
  <source type="video/ogg" src="dizzy.ogv" codecs="theora, vorbis">
</video>
<video controls>
  <source type="video/mp4" src="dizzy.mp4">
  <source type="video/webm" src="dizzy.webm">
  <source type="video/ogg" src="dizzy.ogv">
</video>
<video controls>
  <source src="dizzy.mp4">
  <source src="dizzy.webm">
  <source src="dizzy.ogv">
</video>
<video controls>
  <source src="dizzy-hd.mp4" media="(min-device-height: 720px)">
  <source src="dizzy-regular.mp4">
  <...>
</video>
Video for Everybody
<video width="640" height="360" poster="dizzy.jpg" controls>
  <source src="dizzy.mp4" type="video/mp4" />
  <source src="dizzy.web" type="video/webm" />
  <source src="dizzy.ogv" type="video/ogg" /><!--[if gt IE 6]>
  <object width="640" height="375" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"><!
  [endif]--><!--[if !IE]><!-->
  <object width="640" height="375" type="video/quicktime" data="dizzy.mp4">
  <!--<![endif]-->
  <param name="src" value="dizzy.mp4" />
  <param name="showlogo" value="false" />
  <object width="640" height="380" type="application/x-shockwave-flash"
    data="player.swf?image=dizzy.jpg&amp;file=dizzy.mp4">
    <param name="movie" value="player.swf?image=dizzy.jpg&amp;file=dizzy.mp4" />
    <img src="dizzy.jpg" width="640" height="360" alt="Title of video"
         title="No video playback capabilities, please download the video below" />
  </object><!--[if gt IE 6]><!--></object><!--<![endif]-->
</video>
<p>Download Video: <a href="dizzy.mp4">High Quality "MP4"</a> | <a href="dizzy.ogv">Low Quality "OGG"</a></p>




                         http://camendesign.com/code/video_for_everybody
Scripting
HTML5: where flash isn't needed anymore
var video = document.getElementById('myVideo');
if (video.paused) {
  video.play();
}
var video = document.getElementById('myVideo');
if (video.paused) {
  video.play();
}

// position & asTime defined elsewhere
video.addEventListener('timeupdate', function () {
  positon.innerHTML = asTime(this.currentTime);
}, false);
Simple API
Methods: play(), pause(), canPlayType(mime)

Properties: currentTime, paused, duration,
loop, autoplay, muted, volume, etc

Events: loadedmetadata, canplay, progress,
play, pause, seeking, timeupdate, etc
Fullscreen?
  Warning! User agents should not provide a public API to
cause videos to be shown full-screen. A script, combined with a
carefully crafted video file, could trick the user into thinking a
system-modal dialog had been shown, and prompt the user for
a password. There is also the danger of "mere" annoyance, with
pages launching full-screen videos when links are clicked or
pages navigated. Instead, user-agent specific interface features
may be provided to easily allow the user to obtain a full-screen
playback mode.
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
1. No plugins required
2. Simple API: play, pause, etc
3. Video & Audio: the same
4. HTML & CSS - no compile or
   different skills required
1. Codecs
2.Our friend IE
Flash will be needed
as a backup to video
   for a while yet.
Realtime
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
http://rem.im/collab-drawing.html
WebSocket
•Low latency

• Bi-directional

• No same-original rules

• Chrome, Safari, MobileSafari & Firefox

• Fallback on Flash...ironically
WebSocket
var ws = new WebSocket("ws://myserver.com/");

ws.onmessage = function (event) {
   var data = JSON.parse(event.data);
};

ws.onclose = function () {};

ws.onopen = function () {};
ws.onmessage = function (event) {
   var data = JSON.parse(event.data);
};



   All message data lives here
EventSource
•Server pushed events

• Same-original rules apply

• Can fallback with JavaScript
EventSource
var es = new EventSource("/x-service/");

es.onmessage = function (event) {
   var data = JSON.parse(event.data);
};

es.onopen = function () {};
Graphics
2D Graphics
Canvas
  API
HTML5
<canvas></canvas>




var canvas = document.getElementsByTagName(‘canvas’)[0],
    ctx = canvas.getContext(‘2d’);




            2D drawing API
canvas.getContext(‘2d’)
HTML5: where flash isn't needed anymore
Google Analytics - Flash charts




Interactive Demo - Canvas charts
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
function canvas(w, h) {
  var ctx = document.createElement('canvas').getContext('2d'),
      canvas = ctx.canvas;
  canvas.width = w;
  canvas.height = h;
  return ctx;
}

var rainbow = canvas(100, 1),
    rainbowGrad = createRainbow(rainbow);

rainbow.fillStyle = rainbowGrad;
var imageData = rainbow.getImageData(0, 0, 100, 1),
    pixels = imageData.data;

// loop over each pixel and create the dot image
for (var i = 0; i < pixels.length; i += 4) {
  createPoint(pixels, i);
}
function createPoint(pixels, i) {                  // remove shadow
  var dot = canvas(24, 24);                        dot.shadowBlur = 0;
                                                   dot.shadowColor = 'rgba(0,0,0,0)';
  // outer white circle
  dot.fillStyle = '#fff';                          dot.fillStyle = 'rgb(' + [
  dot.arc(12, 12, 10, 0, Math.PI * 2, true);         pixels[i],   // red
                                                     pixels[i+1], // green
  // drop shadow                                     pixels[i+2] // blue
  dot.shadowBlur = 2;                              ].join(',') + ')';
  dot.shadowColor = 'rgba(0,0,0,.7)';
  dot.shadowOffsetX = 2;                           // start inner circle
  dot.shadowOffsetY = 2;                           dot.beginPath();
                                                   dot.arc(12, 12, 8, 0, Math.PI*2, true);
  // fill outer ring
  dot.fill();                                      // fill inner circle
                                                   dot.fill();

                                                   new google.maps.MarkerImage(
                                                      dot.canvas.toDataURL('image/png')
                                                   );
                                               }
new google.maps.MarkerImage(
   dot.canvas.toDataURL('image/png')
);
HTML5: where flash isn't needed anymore
1. Timer paints video into
   canvas

2. Reads all pixels for bright
   spots

3. Translates to the vector

4. Draws selected input
                                 http://blog.mozbox.org/post/2009/04/12/Firefox-35%3A-a-new-experiment-with-Canvas-Video
1. Flash and canvas share the same
   black box features
2. People will abuse the technology
Scalable
Vector
Graphics
HTML5: where flash isn't needed anymore
...using Flash!
Raphaël.js
3D
CSS
Yeah, 3D CSS.
#canvas {
  -webkit-perspective: 800;
  -webkit-perspective-origin: 50% 20em;
}

#rubiks {
  -webkit-transform-style: preserve-3d;
  -webkit-transform: rotateX(15deg) rotat
}

#rubiks .face1 {
  -webkit-transform: rotateX(90deg) trans
}

#rubiks .face2 { /* front */
  -webkit-transform: translateZ(10.8em);
}

#rubiks .face3 {
  -webkit-transform: rotateY(90deg) trans
}

#rubiks .face4 { /* back face */
  -webkit-transform: rotateY(180deg) tran
}

#rubiks .face5 {
  -webkit-transform: rotateY(-90deg) tran
WebGL
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
Mobile?
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
...or just ask
a question :)


- @rem

More Related Content

PDF
Browsers with Wings
PDF
Yearning jQuery
PDF
iPhone Appleless Apps
PDF
Is HTML5 Ready? (workshop)
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
PDF
Leave No One Behind with HTML5 - FFWD.PRO, Croatia
PPT
Creating the interfaces of the future with the APIs of today
PDF
Sane Async Patterns
Browsers with Wings
Yearning jQuery
iPhone Appleless Apps
Is HTML5 Ready? (workshop)
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
Leave No One Behind with HTML5 - FFWD.PRO, Croatia
Creating the interfaces of the future with the APIs of today
Sane Async Patterns

What's hot (20)

KEY
#NewMeetup Performance
PDF
HTML5 & The Open Web - at Nackademin
PDF
Enjoy the vue.js
PDF
Meetup Performance
PDF
Write Less Do More
PDF
Web Crawling with NodeJS
PDF
jQuery (BostonPHP)
PDF
jQuery (DrupalCamp Toronto)
KEY
[Coscup 2012] JavascriptMVC
PDF
Making your Angular.js Application accessible
PDF
How Kris Writes Symfony Apps
PDF
jQuery (MeshU)
PDF
jQuery: Nuts, Bolts and Bling
PDF
The DOM is a Mess @ Yahoo
PDF
jQuery in 15 minutes
PDF
JavaScript 1.5 to 2.0 (TomTom)
PDF
DOM Scripting Toolkit - jQuery
PPTX
Vue.js + Django - configuración para desarrollo con webpack y HMR
PDF
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
PPTX
How to Build SPA with Vue Router 2.0
#NewMeetup Performance
HTML5 & The Open Web - at Nackademin
Enjoy the vue.js
Meetup Performance
Write Less Do More
Web Crawling with NodeJS
jQuery (BostonPHP)
jQuery (DrupalCamp Toronto)
[Coscup 2012] JavascriptMVC
Making your Angular.js Application accessible
How Kris Writes Symfony Apps
jQuery (MeshU)
jQuery: Nuts, Bolts and Bling
The DOM is a Mess @ Yahoo
jQuery in 15 minutes
JavaScript 1.5 to 2.0 (TomTom)
DOM Scripting Toolkit - jQuery
Vue.js + Django - configuración para desarrollo con webpack y HMR
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
How to Build SPA with Vue Router 2.0
Ad

Similar to HTML5: where flash isn't needed anymore (20)

PDF
How to build a html5 websites.v1
PDF
Google's HTML5 Work: what's next?
PDF
Is html5-ready-workshop-110727181512-phpapp02
PPT
Rotoscope inthebrowserppt billy
PDF
HTML5: friend or foe (to Flash)?
PPTX
Top 10 HTML5 features
PDF
HTML5 video filters
PPT
HTML5 Canvas
PPTX
HTML5 Animation in Mobile Web Games
PDF
I Can't Believe It's Not Flash
PDF
codebits 2009 HTML5 JS APIs
PDF
Mapping the world with Twitter
PDF
Writing a Space Shooter with HTML5 Canvas
PDF
HTML5 APIs - The New Frontier 2011
PDF
Html5apis thenewfrontier-knowit-110203080245-phpapp02
PPTX
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
KEY
Exploring Canvas
PDF
Exploring Canvas
PDF
HTML5 Canvas - The Future of Graphics on the Web
PPTX
Building HTML5 enabled web applications with Visual Studio 2011
How to build a html5 websites.v1
Google's HTML5 Work: what's next?
Is html5-ready-workshop-110727181512-phpapp02
Rotoscope inthebrowserppt billy
HTML5: friend or foe (to Flash)?
Top 10 HTML5 features
HTML5 video filters
HTML5 Canvas
HTML5 Animation in Mobile Web Games
I Can't Believe It's Not Flash
codebits 2009 HTML5 JS APIs
Mapping the world with Twitter
Writing a Space Shooter with HTML5 Canvas
HTML5 APIs - The New Frontier 2011
Html5apis thenewfrontier-knowit-110203080245-phpapp02
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
Exploring Canvas
Exploring Canvas
HTML5 Canvas - The Future of Graphics on the Web
Building HTML5 enabled web applications with Visual Studio 2011
Ad

More from Remy Sharp (14)

PDF
Forget the Web
PDF
Interaction Implementation
PDF
jQuery: out with the old, in with the new
PDF
HTML5: huh, what is it good for?
PDF
HTML5 tutorial: canvas, offfline & sockets
PDF
Developing for Mobile
PDF
Webapps without the web
PDF
TwitterLib.js
PDF
HTML5 JavaScript APIs
PDF
jQuery Loves Developers - Oredev 2009
PDF
HTML5 & Friends
PDF
HTML5 JS APIs
PDF
jQuery Loves Developers - SWDC2009
PDF
Prototype & jQuery
Forget the Web
Interaction Implementation
jQuery: out with the old, in with the new
HTML5: huh, what is it good for?
HTML5 tutorial: canvas, offfline & sockets
Developing for Mobile
Webapps without the web
TwitterLib.js
HTML5 JavaScript APIs
jQuery Loves Developers - Oredev 2009
HTML5 & Friends
HTML5 JS APIs
jQuery Loves Developers - SWDC2009
Prototype & jQuery

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced IT Governance
PDF
KodekX | Application Modernization Development
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
Chapter 2 Digital Image Fundamentals.pdf
Modernizing your data center with Dell and AMD
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
“AI and Expert System Decision Support & Business Intelligence Systems”
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
cuic standard and advanced reporting.pdf
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced IT Governance
KodekX | Application Modernization Development
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Big Data Technologies - Introduction.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Chapter 2 Digital Image Fundamentals.pdf

HTML5: where flash isn't needed anymore

  • 1. HTML5 vs. Flash Where Flash isn’t needed anymore
  • 8. 1. video & Audio 2. Real-time 3. Graphics
  • 11. Who would jump to create another video player?
  • 12. IE9 & all others supported
  • 14. <!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8 /> <title>Video Example</title> </head> <body> <video src="dizzy.mp4" controls></video> </body> </html>
  • 18. <video controls> <source type="video/mp4" src="dizzy.mp4" codecs="avc1.42E01E, mp4a.40.2"> <source type="video/webm" src="dizzy.webm" codecs="vp8, vorbis"> <source type="video/ogg" src="dizzy.ogv" codecs="theora, vorbis"> </video>
  • 19. <video controls> <source type="video/mp4" src="dizzy.mp4"> <source type="video/webm" src="dizzy.webm"> <source type="video/ogg" src="dizzy.ogv"> </video>
  • 20. <video controls> <source src="dizzy.mp4"> <source src="dizzy.webm"> <source src="dizzy.ogv"> </video>
  • 21. <video controls> <source src="dizzy-hd.mp4" media="(min-device-height: 720px)"> <source src="dizzy-regular.mp4"> <...> </video>
  • 22. Video for Everybody <video width="640" height="360" poster="dizzy.jpg" controls> <source src="dizzy.mp4" type="video/mp4" /> <source src="dizzy.web" type="video/webm" /> <source src="dizzy.ogv" type="video/ogg" /><!--[if gt IE 6]> <object width="640" height="375" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"><! [endif]--><!--[if !IE]><!--> <object width="640" height="375" type="video/quicktime" data="dizzy.mp4"> <!--<![endif]--> <param name="src" value="dizzy.mp4" /> <param name="showlogo" value="false" /> <object width="640" height="380" type="application/x-shockwave-flash" data="player.swf?image=dizzy.jpg&amp;file=dizzy.mp4"> <param name="movie" value="player.swf?image=dizzy.jpg&amp;file=dizzy.mp4" /> <img src="dizzy.jpg" width="640" height="360" alt="Title of video" title="No video playback capabilities, please download the video below" /> </object><!--[if gt IE 6]><!--></object><!--<![endif]--> </video> <p>Download Video: <a href="dizzy.mp4">High Quality "MP4"</a> | <a href="dizzy.ogv">Low Quality "OGG"</a></p> http://camendesign.com/code/video_for_everybody
  • 25. var video = document.getElementById('myVideo'); if (video.paused) { video.play(); }
  • 26. var video = document.getElementById('myVideo'); if (video.paused) { video.play(); } // position & asTime defined elsewhere video.addEventListener('timeupdate', function () { positon.innerHTML = asTime(this.currentTime); }, false);
  • 27. Simple API Methods: play(), pause(), canPlayType(mime) Properties: currentTime, paused, duration, loop, autoplay, muted, volume, etc Events: loadedmetadata, canplay, progress, play, pause, seeking, timeupdate, etc
  • 28. Fullscreen? Warning! User agents should not provide a public API to cause videos to be shown full-screen. A script, combined with a carefully crafted video file, could trick the user into thinking a system-modal dialog had been shown, and prompt the user for a password. There is also the danger of "mere" annoyance, with pages launching full-screen videos when links are clicked or pages navigated. Instead, user-agent specific interface features may be provided to easily allow the user to obtain a full-screen playback mode.
  • 31. 1. No plugins required 2. Simple API: play, pause, etc 3. Video & Audio: the same 4. HTML & CSS - no compile or different skills required
  • 33. Flash will be needed as a backup to video for a while yet.
  • 39. WebSocket •Low latency • Bi-directional • No same-original rules • Chrome, Safari, MobileSafari & Firefox • Fallback on Flash...ironically
  • 40. WebSocket var ws = new WebSocket("ws://myserver.com/"); ws.onmessage = function (event) { var data = JSON.parse(event.data); }; ws.onclose = function () {}; ws.onopen = function () {};
  • 41. ws.onmessage = function (event) { var data = JSON.parse(event.data); }; All message data lives here
  • 42. EventSource •Server pushed events • Same-original rules apply • Can fallback with JavaScript
  • 43. EventSource var es = new EventSource("/x-service/"); es.onmessage = function (event) { var data = JSON.parse(event.data); }; es.onopen = function () {};
  • 47. HTML5 <canvas></canvas> var canvas = document.getElementsByTagName(‘canvas’)[0], ctx = canvas.getContext(‘2d’); 2D drawing API
  • 50. Google Analytics - Flash charts Interactive Demo - Canvas charts
  • 54. function canvas(w, h) { var ctx = document.createElement('canvas').getContext('2d'), canvas = ctx.canvas; canvas.width = w; canvas.height = h; return ctx; } var rainbow = canvas(100, 1), rainbowGrad = createRainbow(rainbow); rainbow.fillStyle = rainbowGrad; var imageData = rainbow.getImageData(0, 0, 100, 1), pixels = imageData.data; // loop over each pixel and create the dot image for (var i = 0; i < pixels.length; i += 4) { createPoint(pixels, i); }
  • 55. function createPoint(pixels, i) { // remove shadow var dot = canvas(24, 24); dot.shadowBlur = 0; dot.shadowColor = 'rgba(0,0,0,0)'; // outer white circle dot.fillStyle = '#fff'; dot.fillStyle = 'rgb(' + [ dot.arc(12, 12, 10, 0, Math.PI * 2, true); pixels[i], // red pixels[i+1], // green // drop shadow pixels[i+2] // blue dot.shadowBlur = 2; ].join(',') + ')'; dot.shadowColor = 'rgba(0,0,0,.7)'; dot.shadowOffsetX = 2; // start inner circle dot.shadowOffsetY = 2; dot.beginPath(); dot.arc(12, 12, 8, 0, Math.PI*2, true); // fill outer ring dot.fill(); // fill inner circle dot.fill(); new google.maps.MarkerImage( dot.canvas.toDataURL('image/png') ); }
  • 56. new google.maps.MarkerImage( dot.canvas.toDataURL('image/png') );
  • 58. 1. Timer paints video into canvas 2. Reads all pixels for bright spots 3. Translates to the vector 4. Draws selected input http://blog.mozbox.org/post/2009/04/12/Firefox-35%3A-a-new-experiment-with-Canvas-Video
  • 59. 1. Flash and canvas share the same black box features 2. People will abuse the technology
  • 64. 3D
  • 66. #canvas { -webkit-perspective: 800; -webkit-perspective-origin: 50% 20em; } #rubiks { -webkit-transform-style: preserve-3d; -webkit-transform: rotateX(15deg) rotat } #rubiks .face1 { -webkit-transform: rotateX(90deg) trans } #rubiks .face2 { /* front */ -webkit-transform: translateZ(10.8em); } #rubiks .face3 { -webkit-transform: rotateY(90deg) trans } #rubiks .face4 { /* back face */ -webkit-transform: rotateY(180deg) tran } #rubiks .face5 { -webkit-transform: rotateY(-90deg) tran
  • 67. WebGL
  • 73. ...or just ask a question :) - @rem