2015-09-23 25 views
0

我想通过使用videojs来实现类似http://www.dash-player.com/demo/live-streaming-dvr/之类的东西。videojs:操纵SeekBar的起始值(始终为0),以支持类似DVR/DVR的流式传输

我从wowza流式引擎中获得一个manifest.mpd(type = dynamic),其中timeShiftBufferDepth设置为15分钟。 我使用videojs v4.12.15,dashjs v1.5.0和videojs-contrib-dash v1.1.1来显示流。

正如你所看到的,SeekHandle为0时位置的currentTime的是216:07:07(从manifest.mpd),且持续时间4.99 ...巨大的。 (videojs接缝有一些无限的问题,但在这里并不重要)

当视频进行时,SeekHandle停留在位置0,因为持续时间(巨大的数字)太高,无法达到。 videojs接缝以持续时间的百分比形式提升SeekHandle。当我将持续时间设置为当前时间时,

player.on("timeupdate", function() { 
    this.duration(this.currentTime()); 
}); 

SeekHandle出现在最后。

当我现在尝试在搜索栏寻求,搜索栏包含从00:00:00到的持续时间值(currentTime的== 216:07:07)的值。就流的性质而言,我不能回到流的开始,但是由于dvr我可以回退15分钟。

这意味着,我希望能够从currentTime-15min(215:52:07)到currentTime(216:07:07)。为了达到这个目的,我必须改变SeekBar的初始值,而这正是我迷失的地方。我不知道如何将它从00:00:00改为currentTime-15min(215:52:07)

tl; dr如何在init或更高版本中更改videojs SeekBar的起始值?

+0

嗨,伯纳德,这是一个难题,因为有很多移动部件。尝试更具体地了解一段代码。 “我有这个,我想让它看起来像这样”通常是一个棘手的问题,除非有人已经完成了你正在寻找的东西,你不可能得到一个好的答案...... – Jaap

+0

Hi Jaap,thanks for信息。我已更新我的问题,以更好地陈述我的问题,以及我想知道/得到的答案。 –

回答

0

我的解决办法,如果任何人有类似的问题:

你必须编辑或在原videojs脚本适应以下功能:

vjs.SeekBar.prototype.onMouseMove = function(event){ 
    var newTime = this.calculateDistance(event) * this.player_.duration(); 

    // Don't let video end while scrubbing. 
    if (newTime == this.player_.duration()) { newTime = newTime - 0.1; } 

    // Set new time (tell player to seek to new time) 
    this.player_.currentTime(newTime); 
}; 

this.calculateDistance(event)返回0和1之间的值,其中描述了您在SeekBar上的点击位置。所以如果你在SeekBar的中间点击了,0.5会被返回。

可以说,你想有一个50秒的滑动窗口,那么你必须改变newTime的分配。

var newTime = (this.player_.currentTime() - 50) + (this.calculateDistance(event) * 50); 

例如: 您想在视频中返回25秒。要做到这一点,您只需在它的中间点击SeekBar。该事件被触发,并且this.calculateDistance(event)被设置为0.5。 0.5 * 50正好是25秒。 (this.player_.currentTime() - 50)定义了SeekBar的开始(0%)。添加计算出的25秒会让你找到时间。

你可以在这里看到我的插件:https://gist.github.com/bernhardreisenberger/da0ff4e9a30aa4b6696e 这只是一个原型,并没有完成的插件。SeekHandle仍处于错误的位置和其他问题。