Пример #1
0
 // Keyboard Commands
 function adjustSeek(amount) {
     let min = 0;
     let max = model.get('duration');
     const position = model.get('position');
     if (model.get('streamType') === 'DVR') {
         const dvrSeekLimit = model.get('dvrSeekLimit');
         min = max;
         max = Math.max(position, -dvrSeekLimit);
     }
     const newSeek = utils.between(position + amount, min, max);
     api.seek(newSeek, reasonInteraction());
 }
            return;
        }
        this.setState(STATE_PAUSED);
    },

    progress() {
        var dur = this.getDuration();
        if (dur <= 0 || dur === Infinity) {
            return;
        }
        var buf = this.video.buffered;
        if (!buf || buf.length === 0) {
            return;
        }

        var buffered = utils.between(buf.end(buf.length - 1) / dur, 0, 1);
        this.trigger(MEDIA_BUFFER, {
            bufferPercent: buffered * 100,
            position: this.getCurrentTime(),
            duration: dur
        });
    },

    ratechange() {
        this.trigger(MEDIA_RATE_CHANGE, { playbackRate: this.video.playbackRate });
    },

    ended() {
        this.stopStallCheck();
        this._helperLastVideoHeight = 0;
        if (this.state !== STATE_IDLE && this.state !== STATE_COMPLETE) {
Пример #3
0
    showTimeTooltip(evt) {
        var duration = this._model.get('duration');
        if (duration === 0) {
            return;
        }

        var playerWidth = this._model.get('containerWidth');
        var railBounds = utils.bounds(this.elementRail);
        var position = (evt.pageX ? (evt.pageX - railBounds.left) : evt.x);
        position = utils.between(position, 0, railBounds.width);
        var pct = position / railBounds.width;
        var time = duration * pct;

        // For DVR we need to swap it around
        if (duration < 0) {
            const dvrSeekLimit = this._model.get('dvrSeekLimit');
            duration += dvrSeekLimit;
            time = (duration * pct);
            time = duration - time;
        }

        var timetipText;

        // With touch events, we never will get the hover events on the cues that cause cues to be active.
        // Therefore use the info we about the scroll position to detect if there is a nearby cue to be active.
        if (getPointerType(evt.sourceEvent) === 'touch') {
            this.activeCue = this.cues.reduce((closeCue, cue) => {
                if (Math.abs(position - (parseInt(cue.pct) / 100 * railBounds.width)) < this.mobileHoverDistance) {
                    return cue;
                }
                return closeCue;
            }, undefined);
        }

        if (this.activeCue) {
            timetipText = this.activeCue.text;
        } else {
            var allowNegativeTime = true;
            timetipText = utils.timeFormat(time, allowNegativeTime);

            // If DVR and within live buffer
            if (duration < 0 && time > -1) {
                timetipText = 'Live';
            }
        }
        var timeTip = this.timeTip;

        timeTip.update(timetipText);
        if (this.textLength !== timetipText.length) {
            // An activeCue may cause the width of the timeTip container to change
            this.textLength = timetipText.length;
            timeTip.resetWidth();
        }
        this.showThumbnail(time);

        utils.addClass(timeTip.el, 'jw-open');

        var timeTipWidth = timeTip.getWidth();
        var widthPct = railBounds.width / 100;
        var tolerance = playerWidth - railBounds.width;
        var timeTipPct = 0;
        if (timeTipWidth > tolerance) {
            // timeTip may go outside the bounds of the player. Determine the % of tolerance needed
            timeTipPct = (timeTipWidth - tolerance) / (2 * 100 * widthPct);
        }
        var safePct = Math.min(1 - timeTipPct, Math.max(timeTipPct, pct)).toFixed(3) * 100;
        utils.style(timeTip.el, { left: safePct + '%' });
    }
Пример #4
0
 function adjustVolume(amount) {
     const newVol = utils.between(model.get('volume') + amount, 0, 100);
     api.setVolume(newVol);
 }