Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/controls/vg-playback-button/vg-playback-button.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { VgPlaybackButton } from './vg-playback-button';
import { VgAPI } from '../../core/services/vg-api';
import { ElementRef } from '@angular/core';
import { ElementRef, ChangeDetectorRef } from '@angular/core';
import { VgStates } from '../../core/states/vg-states';

describe('Playback Button', () => {
let playbackButton: VgPlaybackButton;
let ref: ElementRef;
let api: VgAPI;
let cdr: ChangeDetectorRef;

beforeEach(() => {
ref = {
Expand All @@ -27,7 +28,9 @@ describe('Playback Button', () => {
}
};

playbackButton = new VgPlaybackButton(ref, api);
cdr = { detectChanges: () => {}, markForCheck: () => {}, checkNoChanges: () => {}, detach: () => {}, reattach: () => {} };

playbackButton = new VgPlaybackButton(ref, api, cdr);
});

it('Should set playbackIndex default value to 1', () => {
Expand Down
14 changes: 12 additions & 2 deletions src/controls/vg-playback-button/vg-playback-button.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, ElementRef, HostListener, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core';
import { Component, Input, ElementRef, HostListener, OnInit, ViewEncapsulation, OnDestroy, ChangeDetectorRef } from '@angular/core';
import { VgAPI } from '../../core/services/vg-api';
import { Subscription } from 'rxjs';

Expand Down Expand Up @@ -51,7 +51,7 @@ export class VgPlaybackButton implements OnInit, OnDestroy {

ariaValue = 1;

constructor(ref: ElementRef, public API: VgAPI) {
constructor(ref: ElementRef, public API: VgAPI, public cdr: ChangeDetectorRef) {
this.elem = ref.nativeElement;
this.playbackValues = [ '0.5', '1.0', '1.5', '2.0' ];
this.playbackIndex = 1;
Expand Down Expand Up @@ -93,6 +93,8 @@ export class VgPlaybackButton implements OnInit, OnDestroy {
else {
this.target.playbackRate[ this.vgFor ] = (this.playbackValues[ this.playbackIndex ]);
}

this.detectChanges();
}

getPlaybackRate() {
Expand All @@ -103,4 +105,12 @@ export class VgPlaybackButton implements OnInit, OnDestroy {
ngOnDestroy() {
this.subscriptions.forEach(s => s.unsubscribe());
}

detectChanges() {
try {
this.cdr.detectChanges();
} catch(e) {
console.warn(e);
}
}
}
8 changes: 4 additions & 4 deletions src/core/services/vg-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ describe('Videogular Player', () => {

api.seekTime(10);

expect(api.$$seek).toHaveBeenCalledWith(<IPlayable>{id: 'main'}, 10, false);
expect(api.$$seek).toHaveBeenCalledWith(<IPlayable>{id: 'secondary'}, 10, false);
expect(api.$$seek).toHaveBeenCalledWith({id: 'main'} as IPlayable, 10, false);
expect(api.$$seek).toHaveBeenCalledWith({id: 'secondary'} as IPlayable, 10, false);
});

it('Should seek to a specified time by percentage', () => {
Expand All @@ -262,8 +262,8 @@ describe('Videogular Player', () => {

api.seekTime(10, true);

expect(api.$$seek).toHaveBeenCalledWith(<IPlayable>{id: 'main'}, 10, true);
expect(api.$$seek).toHaveBeenCalledWith(<IPlayable>{id: 'secondary'}, 10, true);
expect(api.$$seek).toHaveBeenCalledWith({id: 'main'} as IPlayable, 10, true);
expect(api.$$seek).toHaveBeenCalledWith({id: 'secondary'} as IPlayable, 10, true);
});

it('Should seek media files to a specified time by second', () => {
Expand Down