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(viewer): Update volume icon after UI is loaded #1066

Merged
merged 3 commits into from
Sep 6, 2019
Merged
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
5 changes: 3 additions & 2 deletions src/lib/viewers/media/DashViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,13 @@ class DashViewer extends VideoBaseViewer {
return;
}

this.calculateVideoDimensions();
this.loadUI();

if (this.isAutoplayEnabled()) {
this.autoplay();
}

this.calculateVideoDimensions();
this.loadUI();
this.loadFilmStrip();
this.resize();
this.handleVolume();
Expand Down
15 changes: 9 additions & 6 deletions src/lib/viewers/media/MediaBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ class MediaBaseViewer extends BaseViewer {
.then(() => {
this.startLoadTimer();
this.mediaEl.src = this.mediaUrl;
if (this.isAutoplayEnabled()) {
this.autoplay();
}
})
.catch(this.handleAssetError);
}
Expand All @@ -203,14 +200,20 @@ class MediaBaseViewer extends BaseViewer {
if (this.destroyed) {
return;
}

this.loadUI();

if (this.isAutoplayEnabled()) {
this.autoplay();
}

this.setMediaTime(this.startTimeInSeconds);
this.resize();
this.handleVolume();

this.loaded = true;
this.emit(VIEWER_EVENT.load);

this.loadUI();
this.resize();

// Make media element visible after resize
this.showMedia();

Expand Down
22 changes: 10 additions & 12 deletions src/lib/viewers/media/__tests__/MediaBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ describe('lib/viewers/media/MediaBaseViewer', () => {
beforeEach(() => {
media.mediaEl = document.createElement('video');
media.mediaEl.addEventListener = sandbox.stub();
sandbox.stub(media, 'isAutoplayEnabled').returns(false);
sandbox.stub(media, 'autoplay');
});

it('should load mediaUrl in the media element', () => {
Expand All @@ -138,16 +136,6 @@ describe('lib/viewers/media/MediaBaseViewer', () => {
});
});

it('should autoplay if enabled', () => {
media.isAutoplayEnabled.returns(true);
sandbox.stub(media, 'getRepStatus').returns({ getPromise: () => Promise.resolve() });
media.mediaEl = document.createElement('video');

return media.load().then(() => {
expect(media.autoplay).to.be.called;
});
});

it('should invoke startLoadTimer()', () => {
sandbox.stub(media, 'startLoadTimer');
sandbox.stub(media, 'getRepStatus').returns({ getPromise: () => Promise.resolve() });
Expand Down Expand Up @@ -177,6 +165,16 @@ describe('lib/viewers/media/MediaBaseViewer', () => {
expect(media.showMedia).to.be.called;
expect(document.activeElement).to.equal(media.mediaContainerEl);
});

it('should autoplay if enabled', () => {
sandbox.stub(media, 'isAutoplayEnabled').returns(true);
sandbox.stub(media, 'autoplay');
media.mediaEl = document.createElement('video');

media.loadeddataHandler();

expect(media.autoplay).to.be.called;
});
});

describe('showMedia()', () => {
Expand Down