h5player
h5player copied to clipboard
希望能在页面上不同 video 间切换
-
问题描述 当出现页面上有多个 video 标签时,希望能手动在不同 video 之间切换。
-
出现上述问题的地址 比如 B 站的稍后再看 页面顶端有一个动态 banner,插件会自动 focus 在这上面,导致快捷键不能作用在视频播放器上。手动点击播放器可以暂时使快捷键生效,但几秒后 focus 会重新回到 banner。
-
你使用的浏览器与浏览器版本信息 Chrome 96
-
其他附注信息 动态 banner 的 selector:
#internationalHeader > div.bili-banner > div.animated-banner > div:nth-child(1) > video
B 站稍后再看页面上,手动点击播放器后、随即又会 focus 回 banner 的原因可能是 banner 也在时刻播放中。把脚本中下面一段注释掉可以解决这个问题。
/* 播放器开始播放的时候重新指向实例 */
if (player._hasPlayingRedirectEvent_) return;
player.addEventListener("playing", function (event) {
t.playerInstance = event.target;
t.initPlayerInstance(false);
/* 同步之前设定的播放速度 */
t.setPlaybackRate();
});
player._hasPlayingRedirectEvent_ = true;
Thank you for the report. I don't have an account so I couldn't see that page, but is the banner same/similar here?https://www.bilibili.com/anime/
Was the problem solved with your patch, and did you observe any other unwanted side effects? The change seems to be a bit invasive.
I have another suggestion that seems to solve the problem. I'll come back when it's available to test.
@JAGulin Yes, it's the same banner which appears on the site's homepage as well.
Technically I didn't solve the problem, but with my work-around, after manually clicking on the video player once, it stays focused and then reacts to the hotkeys as it should be.
What would really solve the problem, is that the banner being ignored by default in the initial setting of bilibili.com, or, as I proposed, allowing user to switch between multiple video players on the page.
Thanks for taking care of it!