Javascript 缓存视频播放器
我有以下 Javascript 用于创建视频播放器的 HTML。我使用 Javascript,因为这是我告诉播放器要播放哪个视频的唯一方法。
function createPlayer(videoSource){
document.writeln("<div id=\"player\">");
document.writeln("<object width=\"489\" height=\"414\" >");
document.writeln("<param name=\"player\" value=\"bin-debug/FlexPlayer.swf\">");
//etc
问题是 FlexPlayer.swf 每次都会加载,我需要缓存这个 SWF 文件。也许我应该使用 Javascript 构造函数,但不知道在这种情况下如何使用。任何代码帮助将不胜感激。
I've got the following Javascript for creating the HTML of video player. I use Javascript because this is the only way I can tell the player which video to play.
function createPlayer(videoSource){
document.writeln("<div id=\"player\">");
document.writeln("<object width=\"489\" height=\"414\" >");
document.writeln("<param name=\"player\" value=\"bin-debug/FlexPlayer.swf\">");
//etc
The problem is FlexPlayer.swf is loading every time and I need to cache this SWF file. Maybe I should use Javascript constructor but don't know how in this case. Any code help will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的视频播放器位于 Flex 中(我猜它带有 Flex 标签和 bin-debug 文件夹) - 您应该调用 Flex 应用程序来设置视频。
您可以允许 flex 和 javascript 相互通信,而无需在 HTML 中嵌入不同版本的它!太棒了,看看...
在你的 Flex 应用程序中,初始化后你可以添加类似这样的内容:
上面的作用是公开一个名为“playVideoFromJS”的函数,可以在你的 javascript 中调用该函数来执行“playVideo” ' Flex 应用程序中的功能!整洁的!
然后在你的flex应用程序中的某个地方添加一个像这样的函数:
然后在javascript中,你实际上可以调用你的flex函数playVideo!
有关外部接口的更多信息,请访问:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6#addCallback()
If you're video player is in flex (and I'm guessing that it is with the flex tag and the bin-debug folder) - you should just call into the flex app in order to set the video.
You can allow flex and javascript to communicate with each other, without having to embed different versions of it in the HTML! It's awesome, check it out...
In your flex app, after it is initialized you can add something like this :
What the above does is expose a function named "playVideoFromJS" that can be called in your javascript that will execute the 'playVideo' funciton in the flex app! Neat!
Then add a function like so somewhere in your flex app:
Then in javascript, you can actually call your flex function playVideo!
More information on ExternalInterface here :
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6#addCallback()