JWPlayer 缓存图像
我有一个 Wifi 摄像头,可以将文件通过 FTP 传输到服务器。我想在浏览器窗口中查看最新的文件,就像它是一个不断更新的视频一样,也许每 2 秒 1 帧。
我需要这一切顺利。 (即不重新加载整个页面)。我尝试过 JWPlayer 5.7。问题是,如果我给它一个图像并告诉它使用参数每 2 秒重新加载一次:
jwplayer('mediaspace2').setup({ 'flashplayer': 'mediaplayer-5.7/player.swf', 'duration': '1', 'provider' : 'image', 'file': 'camera/current.jpg', 'controlbar': 'none', 'dock': 'true', 'autostart': 'true', 'repeat': 'always', 'start': '1', 'width': '470', 'height': '300' });
播放器(我怀疑浏览器)会缓存第一个下载的图像,并且它永远不会改变,尽管它在服务器上发生了变化。
有更好的方法吗?或者有一个解决方法,以便我可以获取视频?
他们在 sensr.net 上这样做,但似乎他们扩展了播放器或拥有自己的播放器。
这个问题有解决方法吗?使用播放列表,创建一个单独的更新无缓存帧,或者其他什么?
我认为尝试创建传入图片的 RSTP 流确实很愚蠢,但我还没有弄清楚。
谢谢, -极性
I have a Wifi camera that will FTP files to a server. I want to view the most current file in a browser window like it is a video that constantly gets updated, maybe 1 frame every 2 seconds.
I need this to be smooth. (i.e. not reloading the full page). I've tryed JWPlayer 5.7. The problem is that if I give it an image and tell it to reload it every 2 seconds with the parameter:
jwplayer('mediaspace2').setup({ 'flashplayer': 'mediaplayer-5.7/player.swf', 'duration': '1', 'provider' : 'image', 'file': 'camera/current.jpg', 'controlbar': 'none', 'dock': 'true', 'autostart': 'true', 'repeat': 'always', 'start': '1', 'width': '470', 'height': '300' });
The player (I suspect the browser) caches the first downloaded image and it never changes, although it changes on the server.
Is there a better way to do this? Or a workaround so I can get a video?
They do this on this on sensr.net, but it seems they extend the player or have their own.
Is there a workaround to this problem? Using a playlist, creating a separate updating no-cache frame, or something?
I would think it would really be silly to try to make an RSTP stream of the incoming pictures, but I haven't figured that out yet.
Thanks,
-Polar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Polar -
您可以使用播放器的 JavaScript API 每隔几秒强制一次新加载。只需添加一个随机缓存破坏 URL 参数即可强制浏览器忽略缓存并获取新版本。
或者,您可以尝试在服务器端设置缓存标头,以便在下载后立即使图像过期,但并非所有浏览器都尊重这些标头。
@Polar -
You could use the player's JavaScript API to force a new load every couple of seconds. Just add a random cache-busting URL parameter to force the browser to ignore the cache and grab a new version.
Alternately, you could try setting your cache headers server-side to expire the image immediately after downloading, but not all browsers respect these headers.