Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling .swf From HTML5

Tags:

html

I'm new to HTML5 and am trying to get a simple example working of calling a .swf video file from an HTML button (or similar).

I have gotten this code so far but it doesn't seem to work...

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <video src='test.swf' id='v' controls>
      Your browser does not support HTML5 video.
    </video>
    </br>
    <button onclick="document.getElementById('v').play()">Play</button>
    <button onclick="document.getElementById('v').pause()">Pause</button>
  </body>
</html>

Any help would be appreciated...

like image 647
Ann Sanderson Avatar asked Mar 16 '12 07:03

Ann Sanderson


People also ask

Can HTML5 play SWF files?

Developers who currently create Flash SWF files have several ways to switch to HTML5 including Adobe Animate and Google Web Designer. If you need to play an existing Flash SWF file in your browser alone, you might be able to use Mozilla's Shumway.

How do I view a SWF file in HTML?

You can embed SWF content in HTML content within an AIR application just as you would in a browser. Embed the SWF content using an object tag, an embed tag, or both. Note: A common web development practice is to use both an object tag and an embed tag to display SWF content in an HTML page.

Is HTML5 still used?

HTML5 is several years old now, and as the living standard of the language as a whole, it will only continue to get updated to work with the modern web.


2 Answers

You can use embed tag:

SWF with background

<embed src="main.swf" width="550" height="400" />

SWF WITH transparent background

<embed src="main.swf" width="550" height="400" wmode="transparent" />

SWF WITH FLASHVARS

<embed src="main.swf" width="550" height="400" flashvars="id=hello world" wmode="transparent" />

To control the swf, you need to use External Interface functions.

like image 70
Fábio Nicolau de Lima Avatar answered Oct 18 '22 08:10

Fábio Nicolau de Lima


.swf is not a supported file format for the <video> element the only supported file formats are MPEG-4/H.264 Ogg/Theora and WebM/VP8 with suppport for individual formats varying across browsers.

For information on which browsers support what, refer to the excellent caniuse.com.

For a run down of the HTML5 video element I highly recommend Operas Introduction to HTML5video

like image 26
Simon West Avatar answered Oct 18 '22 06:10

Simon West