Skip to content

Commit

Permalink
fix(player): accept data for fullscreenchange and error events from t…
Browse files Browse the repository at this point in the history
…he tech (#7254)
  • Loading branch information
FredZeng authored Jun 2, 2021
1 parent 11ac0b9 commit 41d5eb3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,8 @@ class Player extends Component {
this.on(this.tech_, 'firstplay', (e) => this.handleTechFirstPlay_(e));
this.on(this.tech_, 'pause', (e) => this.handleTechPause_(e));
this.on(this.tech_, 'durationchange', (e) => this.handleTechDurationChange_(e));
this.on(this.tech_, 'fullscreenchange', (e) => this.handleTechFullscreenChange_(e));
this.on(this.tech_, 'fullscreenerror', (e) => this.handleTechFullscreenError_(e));
this.on(this.tech_, 'fullscreenchange', (e, data) => this.handleTechFullscreenChange_(e, data));
this.on(this.tech_, 'fullscreenerror', (e, err) => this.handleTechFullscreenError_(e, err));
this.on(this.tech_, 'enterpictureinpicture', (e) => this.handleTechEnterPictureInPicture_(e));
this.on(this.tech_, 'leavepictureinpicture', (e) => this.handleTechLeavePictureInPicture_(e));
this.on(this.tech_, 'error', (e) => this.handleTechError_(e));
Expand Down
36 changes: 36 additions & 0 deletions test/unit/player-fullscreen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,39 @@ QUnit.test('fullwindow mode should exit when ESC event triggered', function(asse

player.dispose();
});

QUnit.test('fullscreenchange event from Html5 should change player.isFullscreen_', function(assert) {
const player = FullscreenTestHelpers.makePlayer(false);
const html5 = player.tech(true);

// simulate html5.proxyWebkitFullscreen_
html5.trigger('fullscreenchange', {
isFullscreen: true,
nativeIOSFullscreen: true
});

assert.ok(player.isFullscreen(), 'player.isFullscreen_ should be true');

html5.trigger('fullscreenchange', { isFullscreen: false });

assert.ok(!player.isFullscreen(), 'player.isFullscreen_ should be false');

player.dispose();
});

QUnit.test('fullscreenerror event from Html5 should pass through player', function(assert) {
const player = FullscreenTestHelpers.makePlayer(false);
const html5 = player.tech(true);
const err = new Error('This is test');
let fullscreenerror;

player.on('fullscreenerror', function(evt, error) {
fullscreenerror = error;
});

html5.trigger('fullscreenerror', err);

assert.strictEqual(fullscreenerror, err);

player.dispose();
});

0 comments on commit 41d5eb3

Please sign in to comment.