Skip to content

Commit

Permalink
feat(cvaa): add TEXT_STYLE_CHANGED event (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
yairans authored and Dan Ziv committed Oct 22, 2017
1 parent fa861a9 commit ee67e3c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/event/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ const CUSTOM_EVENTS: { [event: string]: string } = {
* Fires when the player has selected the source to play
*/
SOURCE_SELECTED: 'sourceselected',
/**
* Fires when the text track style has changed
*/
TEXT_STYLE_CHANGED: 'textstylechanged',
/**
* Fired when ad data is available.
*/
Expand Down
1 change: 1 addition & 0 deletions src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ export default class Player extends FakeEventTarget {
sheet.insertRule(`#${this._playerId} .${SUBTITLES_CLASS_NAME} > div > div > div { ${style.toCSS()} }`, 0);
}
this._textStyle = style;
this.dispatchEvent(new FakeEvent(CustomEvents.TEXT_STYLE_CHANGED));
} catch (e) {
Player._logger.error(e.message);
}
Expand Down
1 change: 1 addition & 0 deletions test/src/event/events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('events', () => {
PLAYER_STATE_CHANGED: 'playerstatechanged',
FIRST_PLAY: 'firstplay',
SOURCE_SELECTED: 'sourceselected',
TEXT_STYLE_CHANGED: 'textstylechanged',
AD_LOADED: 'adloaded',
AD_STARTED: 'adstarted',
AD_RESUMED: 'adresumed',
Expand Down
19 changes: 19 additions & 0 deletions test/src/player.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,25 @@ describe('events', function () {
player.play();
});
});

describe('text style changed', () => {
let player;

beforeEach(() => {
player = new Player();
});

afterEach(() => {
player.destroy();
});

it('should fire text style changed', (done) => {
player.addEventListener(player.Event.TEXT_STYLE_CHANGED, () => {
done();
});
player.textStyle = new TextStyle();
});
});
});

describe('states', function () {
Expand Down

0 comments on commit ee67e3c

Please sign in to comment.