Skip to content

Commit

Permalink
fix(buffer and fonts): Fix buffer and fonts on NPM
Browse files Browse the repository at this point in the history
Fixed buffered.end error when metadata is not loaded (close #14). Added fonts to NPM and updated URL
(close #3).

14 3
  • Loading branch information
Elecash committed Feb 6, 2016
1 parent 087d0c4 commit f4d5f51
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 7 deletions.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions src/services/vg-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,35 @@ describe('Videogular Player', () => {
expect((<any>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((<any>api.medias).main.buffered, 'end').and.callThrough();

api.onTimeUpdate('main');

expect((<any>api.medias).main.buffered.end).toHaveBeenCalledWith(0);
});

it('Should handle onProgress event', () => {
api.medias = {
main: {
Expand All @@ -525,6 +554,29 @@ describe('Videogular Player', () => {
expect((<any>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((<any>api.medias).main.buffered, 'end').and.callThrough();

api.onProgress('main');

expect((<any>api.medias).main.buffered.end).toHaveBeenCalledWith(0);
});

it('Should handle onVolumeChange event', () => {
api.onVolumeChange('main');
});
Expand Down
12 changes: 10 additions & 2 deletions src/services/vg-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/vg-player/vg-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f4d5f51

Please sign in to comment.