HTML5 Zone is brought to you in partnership with:

Sapnagroup has been developing web applications for last 10 years. We develop for clients across the globe. Our forte has been the LAMP platform and we have developed complex applications in this domain. Sapna is a DZone MVB and is not an employee of DZone and has posted 6 posts at DZone. You can read more from them at their website. View Full User Profile

Flash to HTML5

01.02.2013
| 3183 views |
  • submit to reddit

 

One of the biggest challenges in last 2-3 years has been showing flash animations on devices like IPAD which do not support flash. One alternative is to convert the Flash animation into an HTML5 animation. One of the tools available for this is Google Swiffy. This is one of the best tools available right now. It does a pretty good job of basic flash animations but any flash with advanced action scripting will not be converted correctly.

Once you have HTML5 animation ready, you will need to do some sniffing and display the HTML5 code instead of the swf file,  for devices like IPAD. We present two alternatives for this.

Check if device is IPAD and show HTML5. Sample PHP code is as below.

if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),’ipad’) > 0) {

TRUE implies device is IPAD. Hence show HTML5 animation

Check if there is flash support on the device. If no support, then show HTML5. This approach will show HTML5 animation on any browser which has flash disabled or which does not have flash support. Sample code is as below.

Download the flash detection java script file from http://www.featureblend.com/javascript-flash-detection-library.html

Include the js file “flashDetect.js”
Add the following code to detect flash

<script type=”text/javascript”>
if(!FlashDetect.installed) {

//Add code here

}
</script>

A similar exercise can be done to show videos via HTML5 as HTML5 has native support for videos via the video tag.

Published at DZone with permission of Sapna Group, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)