选项卡内的视频在 IE 和 Windows 中同时播放铬合金
我正在使用 带有 CSS 和 CSS 的简单选项卡jQuery,但我在使用 IE 和 Chrome 时遇到问题。
我在 3 个不同的选项卡中有视频;在 IE 和 Chrome 中,所有选项卡在页面加载时开始播放,但在 Mozila Firefox 中,它在您单击选项卡时开始播放。 我希望每个选项卡在有人单击它时开始工作。
谁能告诉我如何解决这个问题?
I'm using Simple Tabs w/ CSS & jQuery but I’m having issue with IE and Chrome.
I have videos in 3 different tabs; in IE and Chrome all tabs starting playing when pages load, but in Mozila Firefox it starts playing when you click on the tab.
I want each tab to start working when someone click on it.
Can anyone please tell me how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为当选项卡激活/停用时,您绝对应该明确地将开始/停止操作发送到视频播放器。听起来视频播放器正试图在它变得可见时有足够的意识开始播放(就像在 Firefox 中发生的那样),但您不应该依赖它在任何地方都工作。
您可能很幸运,您的视频播放器有一个支持发送开始/停止操作的 APi。如果没有,请继续阅读:
作为一个 hacky 解决方案,您可以尝试在激活选项卡时将播放器 iframe 的 src 属性设置为正确的路径。我可能会将路径放入框架内的链接中,然后,当激活选项卡时,将链接的
href
属性复制到 iframe 的src
属性。浏览器应加载 iframe 并启动视频。单击另一个选项卡时,将
src
属性移回链接(将 iframesrc
留空。视频将被清除。这样做的优点是保持纯 HTML链接到搜索引擎可访问的视频确实有清除视频时间线的缺点 - 尽管在像您这样的直播情况下,这可能不是问题。
I think you should definitely explicitly send the start/stop actions to the video player when the tabs are activated/deactivated. It sounds like the video player is trying to be aware enough to start playing when it becomes visible (as happens in Firefox), but you shouldn't rely on it working everywhere.
You might be lucky enough that your video player has an APi which supports sending start/stop actions. If not, keep reading:
As a hacky solution, you could try setting the
src
attribute of the player iframe to the correct path when the tab is activated. I'd perhaps put the path into a link inside the frame, then, when the tab is activated, copy thehref
attribute of the link to thesrc
attribute of the iframe. The browser should load the iframe and start the video.When another tab is clicked, move the
src
attribute back to the link (leaving the iframesrc
blank. The video will be cleared.This has the advantage of keeping a plain HTML link to the video accessible to search engines. It does have the drawback of clearing the timeline of the video though - though in a live-stream situation like yours, it's maybe not a problem.