video.js 在不休息播放的情况下搜索时更改 Src [英] video.js Change Src When Seeking Without Resting Playback

查看:38
本文介绍了video.js 在不休息播放的情况下搜索时更改 Src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的视频 src 是一个 AWS 预签名请求 url,它会在 x 天后过期.视频将在 video.js 中正常播放.对于在短暂的url过期时间之后的大视频文件,更改搜索栏会导致网络错误,因为原始src链接已过期.如何在不从视频开头重新启动的情况下使用另一个未过期的预签名 url 刷新 src?我不希望视频回到开头.

My video src is an AWS presigned request url, it expires in x amount of time. The video will start playing just fine in video.js. For large video files after the brief url expiration time, changing the seek bar causes a network error because the original src link has expired. How do you refresh the src with another unexpired presigned url without restarting from the beginning of the video? I don't want the video to go back the beginning.

到目前为止,我发现您可以通过侦听事件 'timeupdate' 和通过事件测试来捕获 e.manuallyTriggered 的变化.

So far I have found that you can capture the change of the seek bar by listening for the event 'timeupdate' and in the passed event testing for e.manuallyTriggered.

谢谢

推荐答案

我今天遇到了同样的问题.我正在使用 plyr 而不是 videojs,所以我不确定你是否能做到这一点,但我的解决方案是:

i had this same issue today. i'm using plyr instead of videojs, so i'm not sure if you can do this exact thing, but my solution was:

  1. 在链接过期并且有人尝试播放/搜索时为播放器绑定一个错误处理程序,然后在处理程序中...
  2. 存储视频的当前时间
  3. 向我的服务器发送 ajax 请求以获取更新的签名 URL
  4. 更新播放器的来源
  5. 将视频的当前时间设置为之前存储的时间

它有点慢/笨重,但这是我目前能想到的最好的解决方法,除了在允许播放之前加载整个视频(这看起来不是很好的用户体验).

it's kind of slow/clunky, but it's the best fix i could come up with at the moment, aside from loading the entire video before allowing playback (which didn't seem like great UX).

更新:这确实适用于 videojs...但它不适用于 Safari 中的任一播放器,这显然根本不发送错误事件.

update: this does work with videojs...but it doesn't work with either player in Safari, which apparently doesn't send the error event at all.

这篇关于video.js 在不休息播放的情况下搜索时更改 Src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆