update() { if (!this.rendered) { // update() is always called after a render return } if (!this.shouldBeVisible()) { this.$el.hide() this.$el.css('left', "-100%") } else { var seekTime = this.getSeekTime() var currentSeekTime = formatTime(seekTime.seekTime, this.useActualLiveTime) // only update dom if necessary, ie time actually changed if (currentSeekTime !== this.displayedSeekTime) { this.$seekTimeEl.text(currentSeekTime) this.displayedSeekTime = currentSeekTime } if (this.durationShown) { this.$durationEl.show() var currentDuration = formatTime(this.actualLiveTime ? seekTime.secondsSinceMidnight : this.duration, this.actualLiveTime) if (currentDuration !== this.displayedDuration) { this.$durationEl.text(currentDuration) this.displayedDuration = currentDuration } } else { this.$durationEl.hide() } // the element must be unhidden before its width is requested, otherwise it's width will be reported as 0 this.$el.show() var containerWidth = this.mediaControl.$seekBarContainer.width() var elWidth = this.$el.width() var elLeftPos = this.hoverPosition * containerWidth elLeftPos -= elWidth / 2 elLeftPos = Math.max(0, Math.min(elLeftPos, containerWidth - elWidth)) this.$el.css('left', elLeftPos) } }
renderSeekBar() { if (this.currentPositionValue === null || this.currentDurationValue === null) { // this will be triggered as soon as these beocome available return } // default to 100% this.currentSeekBarPercentage = 100 if (this.container.getPlaybackType() !== Playback.LIVE || this.container.isDvrInUse()) { this.currentSeekBarPercentage = (this.currentPositionValue / this.currentDurationValue) * 100 } this.setSeekPercentage(this.currentSeekBarPercentage) var newPosition = formatTime(this.currentPositionValue) var newDuration = formatTime(this.currentDurationValue) if (newPosition !== this.displayedPosition) { this.$position.text(newPosition) this.displayedPosition = newPosition } if (newDuration !== this.displayedDuration) { this.$duration.text(newDuration) this.displayedDuration = newDuration } }