diff --git a/src/fonts/videogular.dev.svg b/fonts/videogular.dev.svg similarity index 100% rename from src/fonts/videogular.dev.svg rename to fonts/videogular.dev.svg diff --git a/src/fonts/videogular.eot b/fonts/videogular.eot similarity index 100% rename from src/fonts/videogular.eot rename to fonts/videogular.eot diff --git a/src/fonts/videogular.svg b/fonts/videogular.svg similarity index 100% rename from src/fonts/videogular.svg rename to fonts/videogular.svg diff --git a/src/fonts/videogular.ttf b/fonts/videogular.ttf similarity index 100% rename from src/fonts/videogular.ttf rename to fonts/videogular.ttf diff --git a/src/fonts/videogular.woff b/fonts/videogular.woff similarity index 100% rename from src/fonts/videogular.woff rename to fonts/videogular.woff diff --git a/src/services/vg-api.spec.ts b/src/services/vg-api.spec.ts index 161c9792..a490c3d1 100644 --- a/src/services/vg-api.spec.ts +++ b/src/services/vg-api.spec.ts @@ -501,6 +501,35 @@ describe('Videogular Player', () => { expect((api.medias).main.buffer.end).toBe(40000); }); + it('Should handle onTimeUpdate event before metadata is loaded', () => { + api.medias = { + main: { + id: 'main', + currentTime: 12.345, + duration: 97.317, + buffered: { + length: 0, + end: () => { + return 40; + } + }, + time: { + current: 0, + left: 0 + }, + buffer: { + end: 0 + } + } + }; + + spyOn((api.medias).main.buffered, 'end').and.callThrough(); + + api.onTimeUpdate('main'); + + expect((api.medias).main.buffered.end).toHaveBeenCalledWith(0); + }); + it('Should handle onProgress event', () => { api.medias = { main: { @@ -525,6 +554,29 @@ describe('Videogular Player', () => { expect((api.medias).main.buffer.end).toBe(40000); }); + it('Should handle onProgress event before metadata is loaded', () => { + api.medias = { + main: { + id: 'main', + buffered: { + length: 0, + end: () => { + return 40; + } + }, + buffer: { + end: 0 + } + } + }; + + spyOn((api.medias).main.buffered, 'end').and.callThrough(); + + api.onProgress('main'); + + expect((api.medias).main.buffered.end).toHaveBeenCalledWith(0); + }); + it('Should handle onVolumeChange event', () => { api.onVolumeChange('main'); }); diff --git a/src/services/vg-api.ts b/src/services/vg-api.ts index d114823e..8d00c268 100644 --- a/src/services/vg-api.ts +++ b/src/services/vg-api.ts @@ -236,13 +236,21 @@ export class VgAPI { } onTimeUpdate(id:string) { + var end = this.medias[id].buffered.length - 1; + + if (end < 0) end = 0; + this.medias[id].time.current = this.medias[id].currentTime * 1000; this.medias[id].time.left = (this.medias[id].duration - this.medias[id].currentTime) * 1000; - this.medias[id].buffer.end = this.medias[id].buffered.end(this.medias[id].buffered.length - 1) * 1000; + this.medias[id].buffer.end = this.medias[id].buffered.end(end) * 1000; } onProgress(id:string) { - this.medias[id].buffer.end = this.medias[id].buffered.end(this.medias[id].buffered.length - 1) * 1000; + var end = this.medias[id].buffered.length - 1; + + if (end < 0) end = 0; + + this.medias[id].buffer.end = this.medias[id].buffered.end(end) * 1000; } onVolumeChange(id:string) { diff --git a/src/vg-player/vg-player.ts b/src/vg-player/vg-player.ts index e73ea616..dd4d4008 100644 --- a/src/vg-player/vg-player.ts +++ b/src/vg-player/vg-player.ts @@ -10,11 +10,11 @@ import {VgAPI} from '../services/vg-api'; styles: [` @font-face { font-family: 'videogular'; - src: url('node_modules/videogular2/src/fonts/videogular.eot'); - src: url('node_modules/videogular2/src/fonts/videogular.eot?#iefix') format('embedded-opentype'), - url('node_modules/videogular2/src/fonts/videogular.woff') format('woff'), - url('node_modules/videogular2/src/fonts/videogular.ttf') format('truetype'), - url('node_modules/videogular2/src/fonts/videogular.svg#videogular') format('svg'); + src: url('node_modules/videogular2/fonts/videogular.eot'); + src: url('node_modules/videogular2/fonts/videogular.eot?#iefix') format('embedded-opentype'), + url('node_modules/videogular2/fonts/videogular.woff') format('woff'), + url('node_modules/videogular2/fonts/videogular.ttf') format('truetype'), + url('node_modules/videogular2/fonts/videogular.svg#videogular') format('svg'); font-weight: normal; font-style: normal; }