Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-7266): reposition & resize captions when changing to/from full screen #155

Merged
merged 9 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from 7 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
28 changes: 28 additions & 0 deletions src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export default class Player extends FakeEventTarget {
this._createPlayerContainer();
this._appendPosterEl();
this.configure(config);
this._repositionCuesTimeout = false;
}

// <editor-fold desc="Public API">
Expand Down Expand Up @@ -1157,7 +1158,34 @@ export default class Player extends FakeEventTarget {
this._eventManager.listen(this, Html5Events.RATE_CHANGE, () => {
this._playbackAttributesState.rate = this.playbackRate;
});
this._eventManager.listen(this, CustomEvents.ENTER_FULLSCREEN, () => {
this._resetTextCuesAndReposition();
});
this._eventManager.listen(this, CustomEvents.EXIT_FULLSCREEN, () => {
this._resetTextCuesAndReposition();
});
}
}

/**
* Reset the active cues hasBeenReset = true and then reposition it, timeout here is for the screen to
* finish render the fullscreen
* @returns {void}
* @private
*/
_resetTextCuesAndReposition(): void {
this._updateTextDisplay([]);
for (let i = 0; i < this._activeTextCues.length; i++) {
this._activeTextCues[i].hasBeenReset = true;
}
// handling only the last reposition
if (this._repositionCuesTimeout) {
clearTimeout(this._repositionCuesTimeout);
}
this._repositionCuesTimeout = setTimeout(() => {
processCues(window, this._activeTextCues, this._textDisplayEl);
this._repositionCuesTimeout = false;
}, 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just move this to a const value, REPOSITION_CUES_TIMEOUT and we are good

}

/**
Expand Down
24 changes: 24 additions & 0 deletions test/src/player.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2648,3 +2648,27 @@ describe('_getLanguage', function () {
player._getLanguage(configuredLanguage, offTrack, "text").should.equals(gerTrack.language);
});
});


describe('_resetTextCuesAndReposition', function () {
let config, player, sandbox;

beforeEach(() => {
sandbox = sinon.sandbox.create();
config = getConfigStructure();
player = new Player(config);
});

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

it('should reset the active text cues', () => {
player._activeTextCues[0]={};
player._resetTextCuesAndReposition();
let cue = player._activeTextCues[0];
cue.hasBeenReset.should.equals(true);
});
});