<commit_before>import {Component, Input, ElementRef} from '@angular/core';

import {VgAPI} from '../../../services/vg-api';
import {VgAbstractControl} from '../../vg-abstract-control';

@Component({
    selector: 'vg-scrub-bar-buffering-time',
    template: `<div class="background" [style.width]="getBufferTime()"></div>`,
    styles: [`
        :host {
            display: flex;
            width: 100%;
            height: 5px;
            pointer-events: none;
            position: absolute;
        }

        :host .background {
            background-color: rgba(255, 255, 255, 0.3);
        }

        vg-controls :host {
            position: absolute;
            top: calc(50% - 3px);
        }

        vg-controls :host .background {
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            border-radius: 2px;
        }
    `]
})
export class VgScrubBarBufferingTime extends VgAbstractControl {
    elem:HTMLElement;
    vgFor: string;
    target: any;

    constructor(ref:ElementRef, public API:VgAPI) {
        super(API);
        this.elem = ref.nativeElement;
    }

    onPlayerReady() {
        this.vgFor = this.elem.getAttribute('vg-for');
        this.target = this.API.getMediaById(this.vgFor);
    }

    getBufferTime() {
        var bufferTime = "0%";

        if (this.target && this.target.buffer && this.target.buffered.length) {
            bufferTime = ((this.target.buffer.end / this.target.time.total) * 100) + '%';
        }

        return bufferTime;
    }
}<commit_msg>fix(controls): Fix NaN on VgScrubBarBufferingTime<commit_after>import {Component, Input, ElementRef} from '@angular/core';

import {VgAPI} from '../../../services/vg-api';
import {VgAbstractControl} from '../../vg-abstract-control';

@Component({
    selector: 'vg-scrub-bar-buffering-time',
    template: `<div class="background" [style.width]="getBufferTime()"></div>`,
    styles: [`
        :host {
            display: flex;
            width: 100%;
            height: 5px;
            pointer-events: none;
            position: absolute;
        }

        :host .background {
            background-color: rgba(255, 255, 255, 0.3);
        }

        vg-controls :host {
            position: absolute;
            top: calc(50% - 3px);
        }

        vg-controls :host .background {
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            border-radius: 2px;
        }
    `]
})
export class VgScrubBarBufferingTime extends VgAbstractControl {
    elem:HTMLElement;
    vgFor: string;
    target: any;

    constructor(ref:ElementRef, public API:VgAPI) {
        super(API);
        this.elem = ref.nativeElement;
    }

    onPlayerReady() {
        this.vgFor = this.elem.getAttribute('vg-for');
        this.target = this.API.getMediaById(this.vgFor);
    }

    getBufferTime() {
        var bufferTime = "0%";

        if (this.target && this.target.buffer && this.target.buffered.length) {
            if (this.target.time.total === 0) {
                bufferTime = '0%';
            }
            else {
                bufferTime = ((this.target.buffer.end / this.target.time.total) * 100) + '%';
            }
        }

        return bufferTime;
    }
}
{'fraction_non_alphanumeric': 0.1432083589428396, 'fraction_numerical': 0.015980331899200985, 'mean_word_length': 1.8805309734513274, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2774291', 'n_tokens_mistral': 1059, 'n_tokens_neox': 977, 'n_words': 192}