动态创建 Fancybox 并将视频粘贴到其中
我需要将页面上的所有 HTML5 视频标签替换为附加了点击事件的海报图像;单击事件会启动包含该视频标签的 Fancybox。有人知道如何用 jQuery 做到这一点吗?谢谢。
I need to replace all the HTML5 video tags on the page with their poster image that has a click event attached; the click event launches a Fancybox containing that video tag. Anyone know how to do this with jQuery? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现过去将 fancyBox 与对话视频结合使用的最佳方法是为您的 FLV 播放器创建一个空的 Flash 视频容器 div。然后,在加载 fancyBox 对话框时,您可以使用 fancyBox 上的“onStart”事件来定位容器 div,并用视频播放器内容填充它。然后,这会触发视频在您已经通过 fancyBox 显示的 div 容器中渲染。最后一部分是获取 fancyBox 正确的视频加载后尺寸,这取决于您的 FLV 播放器是否有要连接的事件以及 FLV 播放器是否能够为您提供电影尺寸。
有关此方法的完整教程,请参阅以下网址:
集成的 flowPlayer、fancyBox 和轮播教程。
有关实际演示,请参阅:
集成演示
I've found that in the past the best way to use fancyBox with dialog videos is to create an empty flash video container div for your FLV player. Then on loading your fancyBox dialog you use the on fancyBox 'onStart' event to target the container div, populate it with the video player content. This then triggers the video to render in the div container you are already showing via fancyBox. The last part is getting the dimensions of the fancyBox correct post video load, this depends on your FLV player having an event to hook on to and the FLV player being able to provide you with the movie dimensions.
For a full tutorial on this approach see the following url:
integrated flowPlayer, fancyBox and carousel tutorial.
And for a demonstration of this in action see:
integration demonstration
也许更好的方法是使用一系列包含海报 img 的 div,然后将 onclick 事件附加到海报,以在框中呈现视频标签(或更改视频标签的源)。
Mobile Safari 允许点击事件触发视频播放,因此这也应该适用于 iPad。这也意味着用户无需单击海报图像两次即可播放视频(因为移动 Safari 不支持单击事件)。
Maybe a better way would be to have a series of divs containing the poster img then attach an onclick event to the poster that renders the video tag (or changes the source of the video tag) in the box.
Mobile Safari allows click events to trigger a video to play so this should also work on the iPad. This also means users won't be required to click the poster image twice to play the video (since mobile Safari does not support the click event).
找到了解决办法,调用$(window).load函数;该问题是为了解决 Safari 5/iPad 上的问题。我知道我们不应该使用特定于浏览器的东西,但这是解决这个特定问题的唯一方法:)
Found a solution, called on the $(window).load function; the issue is to address a problem on Safari 5/iPad. I know we're not supposed to use browser-specific stuff, but this is the only way to solve this particular issue :)