0

The site I'm currently working on has a series of videos on a carousel (6 altogether). As you could guess, this is causing us/me some performance headaches, especially regarding the flash-video version.

To help with the CPU usage, I began calling .hide() (we're using jQuery) on the videos as they leave the focus of the carousel. That helped the CPU a lot by itself.

The problem is, each time I call .show() on the object element, I notice an XHR for the video source in Fiddler. I believe this new resource is getting added to memory each time, because I'm seeing a memory leak. I've also tried removing/recreating the element, but I experience the same type of memory leak as with hiding and showing the video.

I've also looked into writing Javascript hooks into the flash file with ActionScript, but I don't have that kind of environment setup, so I'm looking for something strictly javascript.

Is there an effective way to pause/play the video?

Thanks for your time.

4

1 回答 1

1

不幸的是,没有办法告诉 Flash 视频停止使用纯 Javascript 解决方案。如果您有权访问 Actionscript 源,则可以侦听 ExternalInterface 回调并处理暂停代码。

至于通过 Javascript 销毁和重新创建 Flash 对象,如果您使用的是 SWFObject,您可以尝试 removeSWF 方法。它将从源中删除整个对象标记,但我不确定浏览器中的内存管理是什么样的。您可能会面临与以前相同的内存泄漏情况。

我的建议是尝试访问 Flash 源或编写自己的源,以便您可以正确处理暂停和恢复功能。

于 2012-07-02T20:13:49.077 回答