55
Bobby van der Sluis FITC Amsterdam, 26th February 2008

SWFObject 2: The fine art of embedding Adobe Flash Player content

Embed Size (px)

DESCRIPTION

My presentation for FITC Amsterdam. It shortly discusses the history and goals of the SWFObject 2 project, thoroughly explains the underlying problems it aims to solve, and gives an overview of the final solution.

Citation preview

Page 1: SWFObject 2: The fine art of embedding Adobe Flash Player content

Bobby van der SluisFITC Amsterdam, 26th February 2008

Page 2: SWFObject 2: The fine art of embedding Adobe Flash Player content

Many Flash embed methods

• Twice cooked

• Embed only

• Flash Satay

• Nested objects (Hixie)

• Adobe Flash Player Detection Kit

• SWFObject

• Unobtrusive Flash Objects (UFO)

• ObjectSwap

• Many, many other scripts...

Page 3: SWFObject 2: The fine art of embedding Adobe Flash Player content
Page 4: SWFObject 2: The fine art of embedding Adobe Flash Player content

Some methods are on the road to nowhere;none of them are optimal

Page 5: SWFObject 2: The fine art of embedding Adobe Flash Player content

Geoff StearnsSWFObject

Bobby van der SluisUnobtrusive Flash Objects (UFO)

Michael WilliamsAdobe Flash Player Detection Kit

The project

Page 6: SWFObject 2: The fine art of embedding Adobe Flash Player content

8 key questions

1. How to embed cross-browser?

2. How to comply with web standards?

3. What if no Flash plug-in is available?

4. How to deal with an outdated Flash plug-in?

5. Where to download the latest Flash plug-in?

6. How to help search engines?

7. How to avoid mechanisms that hurt the user experience?

8. How to do all of this in the easiest way possible?

Page 7: SWFObject 2: The fine art of embedding Adobe Flash Player content

8 key questions

1. How to embed cross-browser?

2. How to comply with web standards?

3. What if no Flash plug-in is available?

4. How to deal with an outdated Flash plug-in?

5. Where to download the latest Flash plug-in?

6. How to help search engines?

7. How to avoid mechanisms that hurt the user experience?

8. How to do all of this in the easiest way possible?

Page 8: SWFObject 2: The fine art of embedding Adobe Flash Player content

Cross-browser anno 1998

Page 9: SWFObject 2: The fine art of embedding Adobe Flash Player content

Netscape’s <embed>

<embed type="application/x-shockwave-flash" src="myContent.swf" width="780" height="390" />

• Is patented and therefore not a web standard

• Invalid HTML

• Doesn’t support alternative content

Page 10: SWFObject 2: The fine art of embedding Adobe Flash Player content

Alternative content

Content that is accessible to people who browse the web without plugins

Page 11: SWFObject 2: The fine art of embedding Adobe Flash Player content

Internet Explorer’s <object>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="390">

<param name="movie" value="myContent.swf" /> <p>Alternative content</p>

</object>

• Is a W3C Recommendation

• Supports alternative content

• Is a platform specific implementation

Page 12: SWFObject 2: The fine art of embedding Adobe Flash Player content

Twice cooked<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="390">

<param name="movie" value="myContent.swf" /> <embed type="application/x-shockwave-flash" src="myContent.swf" width="780" height="390" />

</object>

• Locked into vendor specific code

• No alternative content possible

• This is still the default publishing method of the Flash IDE today

Page 13: SWFObject 2: The fine art of embedding Adobe Flash Player content

Web standardsoffer a universal language to a whole ecosystem

of browser makers, tool builders, and web authors, so that all of these audiences can avoid

compatibility problems, vendor lock-ins,and patent-infringement issues.

Page 14: SWFObject 2: The fine art of embedding Adobe Flash Player content
Page 15: SWFObject 2: The fine art of embedding Adobe Flash Player content

Cross-browser today All modern web browsers support a platform independent implementation of <object><object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="390"> <p>Alternative content</p></object>

Except Microsoft Internet Explorer<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="390">

<param name="movie" value="myContent.swf" /> <p>Alternative content</p>

</object>

Page 16: SWFObject 2: The fine art of embedding Adobe Flash Player content

Nested objects

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="390">

<param name="movie" value="myContent.swf" />

<object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="390">

<p>Alternative content</p>

</object>

</object>

Page 17: SWFObject 2: The fine art of embedding Adobe Flash Player content

Nested objects - take 2

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="390">

<param name="movie" value="myContent.swf" /><!--[if !IE]>--><object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="390"><!--<![endif]-->

<p>Alternative content</p><!--[if !IE]>--></object><!--<![endif]-->

</object>

Page 18: SWFObject 2: The fine art of embedding Adobe Flash Player content

Why nested objects is better than twice cooked

• It breaks the cycle of vendor lock-in

• Valid HTML

• The opportunity to use alternative content

Page 19: SWFObject 2: The fine art of embedding Adobe Flash Player content

Markup vs scripting

• Around 98% of the people has Flash Player 8

• Around 5% has no JavaScript support

• Around 1% has poor JavaScript support

Page 20: SWFObject 2: The fine art of embedding Adobe Flash Player content

8 key questions

1. How to embed cross-browser?

2. How to comply with web standards?

3. What if no Flash plug-in is available?

4. How to deal with an outdated Flash plug-in?

5. Where to download the latest Flash plug-in?

6. How to help search engines?

7. How to avoid mechanisms that hurt the user experience?

8. How to do all of this in the easiest way possible?

Page 21: SWFObject 2: The fine art of embedding Adobe Flash Player content

The Flash Player will attempt to play Flash content,

no matter what Flash plugin version that content was published for

Page 22: SWFObject 2: The fine art of embedding Adobe Flash Player content

Flash Player version detection

Use JavaScript to:

• Detect the Flash Player version

• Determine whether Flash content or alternative content needs to be shown

• Trigger Adobe Express Install (optional)

Page 23: SWFObject 2: The fine art of embedding Adobe Flash Player content

Adobe Express Install

Page 24: SWFObject 2: The fine art of embedding Adobe Flash Player content

The old way of downloading

<embed ... pluginspage="http://www.macromedia.com/go/getflashplayer" />

Page 25: SWFObject 2: The fine art of embedding Adobe Flash Player content

The old way of downloading

Page 26: SWFObject 2: The fine art of embedding Adobe Flash Player content

The old way of downloading

<object ... codebase="http:// fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">

Page 27: SWFObject 2: The fine art of embedding Adobe Flash Player content

The old way of downloading

Page 28: SWFObject 2: The fine art of embedding Adobe Flash Player content

The modern way of downloading

• Use alternative content

• Use Adobe Express Install (optional)

• Rely on browser built-in mechanisms (based on MIME type invocation)

Page 29: SWFObject 2: The fine art of embedding Adobe Flash Player content
Page 30: SWFObject 2: The fine art of embedding Adobe Flash Player content

8 key questions

1. How to embed cross-browser?

2. How to comply with web standards?

3. What if no Flash plug-in is available?

4. How to deal with an outdated Flash plug-in?

5. Where to download the latest Flash plug-in?

6. How to help search engines?

7. How to avoid mechanisms that hurt the user experience?

8. How to do all of this in the easiest way possible?

Page 31: SWFObject 2: The fine art of embedding Adobe Flash Player content

Doesn’t Google index Flash content?

Page 32: SWFObject 2: The fine art of embedding Adobe Flash Player content

Search engines and Flash content

• Not all search engines index Flash content

• Search engines are far more optimized to index HTML pages than Flash content

• Flash indexing itself is limited: merely flat content in a specific order; it lacks the hierarchical structure and the semantics of HTML

Page 33: SWFObject 2: The fine art of embedding Adobe Flash Player content

Strategies to help search engines

1. Use alternative content

2. Use Sitemaps and robots.txt

Page 34: SWFObject 2: The fine art of embedding Adobe Flash Player content

8 key questions

1. How to embed cross-browser?

2. How to comply with web standards?

3. What if no Flash plug-in is available?

4. How to deal with an outdated Flash plug-in?

5. Where to download the latest Flash plug-in?

6. How to help search engines?

7. How to avoid mechanisms that hurt the user experience?

8. How to do all of this in the easiest way possible?

Page 35: SWFObject 2: The fine art of embedding Adobe Flash Player content

Active content

• Eolas - Microsoft patent dispute

• A user-unfriendly workaround by Microsoft and Opera to avoid claims

• Affects Internet Explorer 6+ and Opera 9+

Page 36: SWFObject 2: The fine art of embedding Adobe Flash Player content

Click-to-activate mechanism

Page 37: SWFObject 2: The fine art of embedding Adobe Flash Player content

Avoiding active content

Publish your Flash contentwith JavaScript

Page 38: SWFObject 2: The fine art of embedding Adobe Flash Player content

No more active content?

• Microsoft has settled with Eolas

• 2008 onwards: click-to-activate mechanism is removed from Internet Explorer via update

• Opera to follow?

• Apple and Opera to be sued next?

Page 39: SWFObject 2: The fine art of embedding Adobe Flash Player content

8 key questions

1. How to embed cross-browser?

2. How to comply with web standards?

3. What if no Flash plug-in is available?

4. How to deal with an outdated Flash plug-in?

5. Where to download the latest Flash plug-in?

6. How to help search engines?

7. How to avoid mechanisms that hurt the user experience?

8. How to do all of this in the easiest way possible?

Page 40: SWFObject 2: The fine art of embedding Adobe Flash Player content
Page 41: SWFObject 2: The fine art of embedding Adobe Flash Player content

SWFObject 2.0

• Static publishing method

• Dynamic publishing method

• JavaScript API

• Only utilizes 1 JavaScript file (9.2 Kb)

Page 42: SWFObject 2: The fine art of embedding Adobe Flash Player content

Static publishing method

Embed Flash content and alternative contentusing standards compliant markup,

and use unobtrusive JavaScript to resolve the issuesthat markup alone cannot solve

Page 43: SWFObject 2: The fine art of embedding Adobe Flash Player content

Static publishing - step 1

<object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="390"><param name="movie" value="myContent.swf" /><!--[if !IE]>--><object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="390"><!--<![endif]-->

<p>Alternative content</p><!--[if !IE]>--></object><!--<![endif]-->

</object>

Page 44: SWFObject 2: The fine art of embedding Adobe Flash Player content

Static publishing - step 2

<script type="text/javascript" src="swfobject.js"></script>

Page 45: SWFObject 2: The fine art of embedding Adobe Flash Player content

Static publishing - step 3

<script type="text/javascript">swfobject.registerObject("myId", "9.0.0");</script>

Page 46: SWFObject 2: The fine art of embedding Adobe Flash Player content

Dynamic publishing method

Create alternative content using standards compliant markup and embed

Flash content with unobtrusive JavaScript

Page 47: SWFObject 2: The fine art of embedding Adobe Flash Player content

Dynamic publishing - step 1

<div id="myId"> <p>Alternative content</p></div>

Page 48: SWFObject 2: The fine art of embedding Adobe Flash Player content

Dynamic publishing - step 2

<script type="text/javascript" src="swfobject.js"></script>

Page 49: SWFObject 2: The fine art of embedding Adobe Flash Player content

Dynamic publishing - step 3

<script type="text/javascript">swfobject.embedSWF("myContent.swf", "myId", "780", "390", "9.0.0");</script>

Page 50: SWFObject 2: The fine art of embedding Adobe Flash Player content
Page 51: SWFObject 2: The fine art of embedding Adobe Flash Player content
Page 52: SWFObject 2: The fine art of embedding Adobe Flash Player content

JavaScript API

• swfobject.registerObject(...)• swfobject.embedSWF(...)

• swfobject.getObjectById(...)• swfobject.getFlashPlayerVersion()• swfobject.hasFlashPlayerVersion(...)• swfobject.addLoadEvent(...)• swfobject.addDomLoadEvent(...)• swfobject.createSWF(...)• swfobject.createCSS(...)• swfobject.getQueryParamValue(...)

Page 53: SWFObject 2: The fine art of embedding Adobe Flash Player content

SWFObject 2.0 and browser integration

• As usual, e.g.:- Adobe External Interface- SWFAddress 2.0- AS3.0 MouseWheel on Mac OSX

• One catch with static publishing:

Use swfobject.getObjectById("myId") to retrieve the active <object>

Page 54: SWFObject 2: The fine art of embedding Adobe Flash Player content

SWFObject 2.0 and accessibility

• Create Flash content (for visitors with the right plug-in/JavaScript support)

• Create alternative HTML content (for visitors that don’t have the right support)

• Make your Flash content accessible

• Make your HTML content accessible

Page 55: SWFObject 2: The fine art of embedding Adobe Flash Player content

LinksThis presentation will soon be posted at:

http://www.bobbyvandersluis.com

SWFObject 2.0: http://code.google.com/p/swfobject/

SWFFix/SWFObject 2.0 dev blog: http://www.swffix.org

Flash embedding cage match: http://www.alistapart.com/articles/flashembedcagematch/

Flash Player embed test suite: http://www.swffix.org/testsuite/