Does the swf file download to user's PC before it starts playing/How does Flash Files play on user's PC

1

1

I would like to know how a flash file plays/loads in the users PC. For instance, if my code is as below -

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="970" height="490" id="PRE" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="cmck_rhp_pre.swf" /><param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />    
<embed src="PRE.swf" quality="high" bgcolor="#ffffff" width="970" height="490" name="PRE" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

The PRE.swf file is about 413KB. When the user launches this page, how does the file actually play, as in, does the 413KB download to the user's PC and then starts to play or ...? Basically, I would like to know how flash files, be it swf or flv, play on a user's PC. This is in order to understand the impact before deploying.

UPDATE 1: If I open the swf file by typing in \\\PRE.swf, in the IE, the flash file plays. However, I do not see anything in the Temporary Internet Files folder.

Kanini

Posted 2009-11-11T12:39:01.013

Reputation: 1 102

stackoverflow ? – ukanth – 2009-11-11T12:53:13.970

1I too thought so, but since it is not exactly programming related, I thought I will post it here. In fact, I have the question ready to be posted on SO as well. – Kanini – 2009-11-11T13:14:38.640

1@Kanini, no, please don't multipost the same question on Stack Overflow. If people think it belongs there (which I don't), then this very question will be moved. – Arjan – 2009-11-11T13:42:13.057

Thanks Arjan, which is why I have not posted it in SO. – Kanini – 2009-11-12T10:07:14.043

Answers

4

In fact, Flash movies (animation) start playing as soon as the first frame is downloaded completely, while the rest of the SWF file downloads in the background. You know those "this many percent" displays that long Flash animations put up? We Flash developers call them "preloaders", and they're there to prevent the movie from starting before it's largely or completely downloaded, so you don't get stuttering and pauses if the player tries to play frames that aren't downloaded yet

The entire SWF does get downloaded, but play starts before that.

CarlF

Posted 2009-11-11T12:39:01.013

Reputation: 8 576

2

Just to be sure you don't confuse things: some people refer to SWF files as "Flash movies". Others use that term only for FLV (Flash video) files.

On websites, SWF is played in the Flash player, while FLV files are played by a (small, re-usable) SWF file that shows the screen and its controls (play, pause, forward, full screen, ...) and which itself is played in the Flash player.

As far as I understand, SWF file often (or always?) are downloaded all the way before playing really starts, but Flash allows for displaying a custom animated splash screen while downloading is in progress. FLV files do not need to be downloaded all the way before playing starts, and the SWF player often also allows for skipping parts of the FLV without ever downloading it (if the server supports that too).

The Flash player uses its own cache, shared (for the current user) with all browsers on your machine.

(Also note that the <object> and <embed> thing in your example are different ways to get the same thing done in different browsers.)

Arjan

Posted 2009-11-11T12:39:01.013

Reputation: 29 084

1

The full flash file is downloaded prior to executing. You won't see anything in your cache when viewing it like that because you're running it locally, it doesn't need to make another copy on the hard disk.

John T

Posted 2009-11-11T12:39:01.013

Reputation: 149 037

Thanks John. However, if I have viewed it once and then if I close/reopen the browser to the URL, will it be downloaded again? – Kanini – 2009-11-11T13:06:30.487

You didn't get the point Kanini - you're already running it locally there's no need for the hard disk to make another copy. – Charlls – 2009-11-11T13:33:34.500

Ah, I see where the problem is. What I wanted to mean was - if I access it via the browser, I still do not see it on the local cache. Let us for the time being, forget accessing it that way. If I access it via the HTML page, close the browser window and the reopen it and access it, will it be downloaded again? Have I atleast got it right this time around? – Kanini – 2009-11-11T13:43:29.543

If you access it via the browser using http protocol, it will be downloaded the first time if not in the cache, and accessed from the cache subsequently if it hasn't expired yet. Whether the caching is taking place is dependent on the HTTP headers your web server sends with the SWF. – Chris W. Rea – 2009-11-11T14:03:42.950

1

It's not caching locally because it's already local! You're not using your browser to HTTP request the flash file from a remote server > therefor no need to copy to cache.

Use one of two methods to ensure SWF files are downloaded each time:

Using the 'Expires' header. The Expires header of an HTML document tells a Web browser when a cached document should expire from the cache. Using a date in the past ensures the document will always be expired.

 <!-- BEGIN INSERT --><META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999 21:29:02 GMT"><!-- END INSERT --> 

Each and every time this document is requested the browser will notice that the cached version has expired and will download the file from it's server of origin. Using the Pragma: No-Cache header. This code directs the browser to not cache the document at all.

<!-- BEGIN INSERT --><HEAD><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"></HEAD><!-- END INSERT --> 

Charlls

Posted 2009-11-11T12:39:01.013

Reputation: 1 369

The <meta> tag only applies to the HTML (and should match any values set in the HTTP headers). Any embedded media can only rely on the HTTP headers. One can see those online at, for example, http://web-sniffer.net

– Arjan – 2009-11-11T14:11:13.207