Skip to content

Commit

Permalink
fix(player): Added missing events to display/hide loader image
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa8626 committed Nov 14, 2018
1 parent e87466a commit d7808f0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
24 changes: 22 additions & 2 deletions dist/openplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,25 @@ var Player = function () {
};

this.events.waiting = function () {
var el = _this3.activeElement();

_this3.playBtn.setAttribute('aria-hidden', 'true');

_this3.loader.setAttribute('aria-hidden', el instanceof media_1.default ? 'false' : 'true');
};

this.events.durationchange = function () {
var el = _this3.activeElement();

_this3.playBtn.setAttribute('aria-hidden', 'true');

_this3.loader.setAttribute('aria-hidden', 'false');
_this3.loader.setAttribute('aria-hidden', el instanceof media_1.default ? 'false' : 'true');
};

this.events.canplay = function () {
_this3.playBtn.setAttribute('aria-hidden', 'true');

_this3.loader.setAttribute('aria-hidden', 'true');
};

this.events.seeking = function () {
Expand All @@ -1692,17 +1708,21 @@ var Player = function () {
};

this.events.play = function () {
var el = _this3.activeElement();

_this3.playBtn.classList.add('op-player__play--paused');

setTimeout(function () {
_this3.playBtn.setAttribute('aria-hidden', 'true');

_this3.loader.setAttribute('aria-hidden', 'true');
_this3.loader.setAttribute('aria-hidden', el instanceof media_1.default ? 'false' : 'true');
}, 350);
};

this.events.playing = function () {
_this3.playBtn.setAttribute('aria-hidden', 'true');

_this3.loader.setAttribute('aria-hidden', 'true');
};

this.events.pause = function () {
Expand Down
2 changes: 1 addition & 1 deletion dist/openplayer.min.js

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions src/js/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Player {
* @type string|string[]
* @memberof Player
*/
private ads?: string|string[];
private ads?: string | string[];

/**
* Flag to determine if player must be scaled and scrop to fit parent container
Expand Down Expand Up @@ -256,7 +256,7 @@ class Player {
* @returns {Player}
* @memberof Player
*/
constructor(element: HTMLMediaElement | string, ads?: string|string[], fill?: boolean, options?: PlayerOptions) {
constructor(element: HTMLMediaElement | string, ads?: string | string[], fill?: boolean, options?: PlayerOptions) {
this.element = element instanceof HTMLMediaElement ? element : (document.getElementById(element) as HTMLMediaElement);
if (this.element) {
this.ads = ads;
Expand Down Expand Up @@ -697,8 +697,18 @@ class Player {
}
};
this.events.waiting = () => {
const el = this.activeElement();
this.playBtn.setAttribute('aria-hidden', 'true');
this.loader.setAttribute('aria-hidden', el instanceof Media ? 'false' : 'true');
};
this.events.durationchange = () => {
const el = this.activeElement();
this.playBtn.setAttribute('aria-hidden', 'true');
this.loader.setAttribute('aria-hidden', 'false');
this.loader.setAttribute('aria-hidden', el instanceof Media ? 'false' : 'true');
};
this.events.canplay = () => {
this.playBtn.setAttribute('aria-hidden', 'true');
this.loader.setAttribute('aria-hidden', 'true');
};
this.events.seeking = () => {
const el = this.activeElement();
Expand All @@ -711,14 +721,16 @@ class Player {
this.loader.setAttribute('aria-hidden', 'true');
};
this.events.play = () => {
const el = this.activeElement();
this.playBtn.classList.add('op-player__play--paused');
setTimeout(() => {
this.playBtn.setAttribute('aria-hidden', 'true');
this.loader.setAttribute('aria-hidden', 'true');
this.loader.setAttribute('aria-hidden', el instanceof Media ? 'false' : 'true');
}, 350);
};
this.events.playing = () => {
this.playBtn.setAttribute('aria-hidden', 'true');
this.loader.setAttribute('aria-hidden', 'true');
};
this.events.pause = () => {
this.playBtn.classList.remove('op-player__play--paused');
Expand Down

0 comments on commit d7808f0

Please sign in to comment.