浏览器如何加载 Flash 文件? (swf)

发布于 2024-11-29 20:20:40 字数 216 浏览 1 评论 0原文

浏览器如何加载flash文件?它们是逐步加载,还是浏览器会等到整个 Flash 文件加载完毕后再显示?

原因是我有一个质量极高的小剪辑,只有几秒钟长,但它超过 4 mb。

用户是否必须等到所有 4 MB 加载完毕才能查看?或者它会在用户观看时加载吗?

我没有做任何花哨的事情,我只是将 .flv 导入到 Flash 中,然后导出为 .swf。

提前谢谢您

How does the browser load flash files? Do they load progressively, or does the browser wait until the entire flash file is loaded before displaying it?

The reason is I have a tiny clip that is extremely high in quality, only a few seconds long, but it's over 4 mb.

Will the user have to wait until all 4 mb is loaded before viewing? Or does it load as the user watches it?

I didn't do anything fancy, I just imported a .flv into Flash, and exported as a .swf.

Thank you in advanced

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

从此见与不见 2024-12-06 20:20:40

加载 Flash 文件(更一般地说,加载 HTML 页面)有很多部分。

我将从 HTML 页面的顶部开始,并敦促其他人纠正我可能犯的任何错误。

加载页面

当收到 HTML 页面时,浏览器将其解析为文档对象模型 (DOM),以便它具有每个元素的编程表示。浏览器迭代 DOM 树中的每个节点并根据需要填充它。

对于大多数节点来说,这只是创建一个新的 DOM 元素,例如 divpa;但是某些内容需要加载或替换。

表单元素(inputselectbuttontextarea)被替换为这些表单的浏览器特定表示形式字段。

用作样式表的 link 元素是异步加载的。当外部资源被加载时,DOM 继续解析页面。

另一方面,script 元素是同步加载的。在脚本完成加载和执行之前,DOM 无法继续解析树,加载失败或执行出错的情况除外。

img 元素是异步加载的,但允许 onload 回调来确定它们何时完成加载。在所有 img 元素完成加载(或失败)之前,DOM 无法触发窗口的 onload 事件。

了解基本元素有助于理解更多涉及的元素,例如 objectembediframe,这些元素也是替换内容。

Flash 通常使用objectembediframe 嵌入到网页上。

据我所知,objectembed 元素的反应类似,因此我将快捷方式从这里开始说 object

iframeobject 元素中加载 Flash 之间存在明显差异。

object 元素与 script 元素非常相似,其中内容必须成功加载并执行,然后才能继续解析 DOM。

iframe 元素与 img 元素非常相似,其中内容是异步加载的,但是可以使用回调来确定加载何时完成(尽管我不确定回调是否可用于跨域请求)

加载 Flash

上一节讨论内容加载的 HTML 部分。然而,Flash 中存在许多细微差别,可能会严重影响 Flash 影片的加载时间。

正如我之前所说,script 元素必须完全加载并执行,然后才能继续解析 DOM。 Flash 文件中也存在类似的效果(即使是通过 iframe 包含的)。必须先加载 swf 中嵌入的所有资源,然后 swf 才能释放其对页面加载进度的控制。

如果您已将视频直接嵌入到时间线中,则必须先加载整个视频,然后才能将 Flash 视为完成其初始执行。

相反,如果您选择使用异步回调来开始加载恰巧是视频的外部资源,并使用异步加载器来加载视频,则无需等待视频加载完成。页面的其余部分可以加载;在 Flash 中,您仍然需要等待视频加载完成才能开始播放视频。

或者,flash 中有多种方法可以流式传输视频或从服务器逐步加载视频,这将使视频能够在未完成加载的情况下播放。 我对 Flash 特定方面的经验很少,因此我不会解释如何它是如何完成的

使用像 swfobject 这样的库可以异步加载所需的 swf,以便 Flash 加载是非阻塞的。

TL; dr:

Flash 文件可能会逐渐加载,具体取决于您构建 HTML 的方式以及 swf 中运行的代码。

您可能需要查看 swfobject

There are many parts to loading a flash file, and more generically, an HTML page.

I'm going to start from the top with the HTML page, and I urge others to correct any mistakes I may have made.

Loading a Page

When an HTML page is received, the browser parses it into the Document Object Model (DOM) so that it has a programmatic representation of every element. Browsers iterate over every node in the DOM tree and populate it as-needed.

For most nodes this is simply creating a new DOM element like a div, p, or a; however some content requires loading or replacement.

form elements (input, select, button, textarea) are replaced with the browser-specific representation of those form fields.

link elements used as stylesheets are asynchronously loaded. The DOM continues to parse the page as the external resource is being loaded.

script elements on the other hand, are synchronously loaded. The DOM is unable to continue parsing the tree until the script has finished loading and executing, with exceptions for if the loading failed or the execution had an error.

img elements are asynchronously loaded, but allow for the onload callback to determine when they have finished loading. The DOM can't trigger the window's onload event until all img elements have finished loading (or failed).

Understanding the basic elements helps with understanding more involved elements like object, embed, and iframe, which are also replaced content.

Flash is typically embedded on a webpage using object, embed and iframe.

As far as I'm aware, object and embed elements react similarly so I will shortcut and say object from here on out.

There are distinct differences between loading flash in iframe and object elements.

The object element is very similar to a script element where the content must be successfully loaded and executed before the DOM can continue to be parsed.

The iframe element is very similar to an img element where the contents are loaded asynchronously, but a callback may be used to determine when the loading has finished (although I'm not sure about whether the callback is available for cross-domain requests).

Loading Flash

The previous section discusses just the HTML side of content loading. However, there are a number of nuances within flash that can severely affect the load time of a flash movie.

As I stated before, script elements must be fully loaded and executed before the DOM can continue being parsed. A similar effect is found within Flash files (even when included via an iframe). All resources embedded within the swf must be loaded before the swf can release its hold on the page loading progress.

If you've embedded a video directly into the timeline, the entire video must load before flash can be considered done with its initial execution.

If, instead, you chose to use an asynchronous callback to start loading an external resource that happened to be a video, and used an asynchronous loader to load the video, you wouldn't have to wait for the video to be finished loading before the rest of the page could be loaded; within flash, you'd still need to wait for the video to finish loading before beginning playback of the video.

Alternatively, there are a number of means within flash to either stream videos, or progressively load a video from a server, which would enable the video to be played without being finished loading. My experience with that particular aspect of flash is minimal, so I won't explain how it's done.

Using a library like swfobject allows the desired swf to be loaded asynchronously so that flash loading is non-blocking.

tl; dr:

Flash files may be loaded progressively depending on how you've structured your HTML, and what code is running in the swf.

You may want to look into swfobject

旧瑾黎汐 2024-12-06 20:20:40

swf 文件是逐步加载的(因此加载器栏、“50% 已加载”消息等)。

从历史上看,Flash文件是基于帧的,如果主时间轴有多个帧,它们将按顺序加载并显示,一旦加载,就会在整个文件加载之前。然而,现在的大多数 Flash 内容并不是这样构建的,并且比一系列按顺序显示的帧更为复杂。视频播放还增加了基本帧模型之外的复杂性,包括视频编解码器、音频同步等。

因此,“它们是渐进式加载,还是浏览器会等到整个 Flash 文件加载完毕后再显示?”这个问题的答案是,它们是渐进式加载,并在整个 swf 文件加载之前显示。已加载。但是,如果没有看到视频或视频的构建方式,很难判断这将如何影响用户体验视频的方式。

swf files are loaded progressively (hence loader bars, "50% loaded" messages and such).

Historically, Flash files are based on frames, and if the main timeline has multiple frames, they will be loaded and displayed in sequence, as soon as they are loaded, before the entire file is loaded. However, most Flash content nowadays is not constructed that way, and are more complex than a series of frames that are displayed in sequence. Video playback also adds complexity beyond the basic frame model, with video codecs, audio synch and such.

So the answer to the question "Do they load progressively, or does the browser wait until the entire flash file is loaded before displaying it?" is that they load progressively and are displayed before the entire swf files is loaded. But how this will effect how the users experience your video is hard to tell without seeing it or how it is constructed.

墨小沫ゞ 2024-12-06 20:20:40

它将首先加载整部电影。因此,请将您的视频作为电影运行时加载的外部文件。

It will load the entire movie first. So make your video an external file that the movie loads when it runs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文