• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05.2011
 

HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05.2011

on

  • 4,680 views

 

Statistics

Views

Total Views
4,680
Views on SlideShare
4,620
Embed Views
60

Actions

Likes
3
Downloads
260
Comments
0

3 Embeds 60

http://my.opera.com 32
http://www.techgig.com 22
http://lanyrd.com 6

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05.2011 HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05.2011 Presentation Transcript

    • HTML5 APIsNATIVE MULTIMEDIA SUPPORT AND BEYONDPatrick H. Lauke / University of Leeds / 5 May 2011
    • “...extending the language to better supportWeb applications [...] This puts HTML indirect competition with othertechnologies[...] , in particular Flash andSilverlight.”Ian Hickson, Editor of HTML5http://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> <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>
    • <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.264ubiquitous, patent encumbered, licensing/royalties
    • Ogg Theora“free and open”, no licensing/royaltiesnot many tools for it, not web optimised
    • WebMopen and royalty-free, web optimised
    • 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> elementvar v = document.getElementById(player);v.play();v.pause();v.volume = … ;v.currentTime = … ;…
    • events fired by <video> elementvar 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)…
    • people.opera.com/patrickl/experiments/webm/basic-controls
    • people.opera.com/patrickl/experiments/webm/fancy-controls
    • people.opera.com/patrickl/experiments/webm/fancy-swap
    • <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 drawingctx = 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);
    • people.opera.com/patrickl/experiments/canvas/particle/3
    • mariuswatz.com/works/abstract01js
    • www.benjoffe.com/code/demos/canvascape
    • 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
    • www.splintered.co.uk/experiments/archives/paranoid_0.3
    • 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, … ]
    • www.splintered.co.uk/experiments/archives/canvas-ambilight
    • github.com/mezzoblue/PaintbrushJS
    • 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)
    • html5doctor.com/video-canvas-magic
    • media.chikuyonok.ru/ambilight
    • www.filamentgroup.com/examples/charting
    • canvas accessibility concerns
    • video, audio and canvas on any device without plugins (Java / Flash / Silverlight not ubiquitous)
    • HTML5 (and friends) haslots more APIs for developers (for powerful client-side apps)
    • isgeolocationpartofhtml5.com
    • geolocationnavigator.geolocation.getCurrentPosition(success, error);navigator.geolocation.watchCurrentPosition(success, error);function success(position) { /* wheres Wally? */ var lat = position.coords.latitude; var long = position.coords.longitude; ...}
    • owlsnearyou.com
    • offline detectionwindow.addEventListener(online, function(){ … }, true);window.addEventListener(offline, function(){ … }, true); …however, currently unreliable!
    • application cache<html manifest=”blah.manifest”>CACHE MANIFEST# send this with correct text/cache-manifest MIMEimages/sprites.pngscripts/common.jsscripts/jquery.jsstyles/global.cssNETWORK:# never cached (apart from normal caching mechanism)onlineonly.cssFALLBACK:# pattern matching. fallback file will also be cachedimages/ images/not-offline.png
    • localStorage/sessionStoragelike cookies...document.cookie = key=value; expires=Thu, 15 Feb 201023:59:59 UTC; path=/…/* convoluted string operations go here … */
    • localStorage/sessionStoragelike cookies...on steroids!localStorage.setItem(key, value);localStorage.getItem(key);localStorage.clear();localStorage.key = value;if (localStorage.key == …) { … }…
    • WebSQLrelational DB / SQL in browservar db =openDatabase(dbName, version, displayName, expectedSize);db.transaction(function(tx) { tx.executeSql(sqlStatement, [], function (tx, result) { /* do something with the results */ });});not being developed further (IE/Mozilla prefer IndexedDB)– nonetheless available right now in Opera+WebKit!
    • is it all safe to use, right now?
    • dont do browser sniffing http://www.flickr.com/photos/timdorr/2096272747/
    • feature-detectionprogressive enhancement, graceful degradation – or use shims http://diveintohtml5.org/everything.html
    • feature-detection for audio/videoif (!!document.createElement(video).canPlayType;) { … }if (!!document.createElement(audio).canPlayType;) { … }
    • feature-detection for audio/video codecsvar 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 patrick.lauke@opera.com