Skip to content

Commit

Permalink
Fix: Restore crawler for buffering video (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored Jul 17, 2017
1 parent 38ecce7 commit 800692d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/PreviewUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SELECTOR_BOX_PREVIEW_BTN_PRINT,
SELECTOR_BOX_PREVIEW_BTN_DOWNLOAD,
SELECTOR_BOX_PREVIEW_BTN_LOADING_DOWNLOAD,
SELECTOR_BOX_PREVIEW_CRAWLER_WRAPPER,
SELECTOR_BOX_PREVIEW_LOADING_TEXT,
SELECTOR_BOX_PREVIEW_LOADING_WRAPPER,
SELECTOR_BOX_PREVIEW_LOGO_CUSTOM,
Expand Down Expand Up @@ -248,6 +249,12 @@ class PreviewUI {
hideLoadingIndicator() {
if (this.contentContainer) {
this.contentContainer.classList.add(CLASS_PREVIEW_LOADED);
const crawler = this.contentContainer.querySelector(SELECTOR_BOX_PREVIEW_CRAWLER_WRAPPER);
if (crawler) {
// We need to remove this since it was hidden specially as a
// part of finishLoadingSetup in BaseViewer.js
crawler.classList.remove(CLASS_HIDDEN);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/lib/__tests__/PreviewUI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ describe('lib/PreviewUI', () => {
ui.hideLoadingIndicator();
expect(contentContainerEl).to.have.class(constants.CLASS_PREVIEW_LOADED);
});

it('should remove the hidden class from the crawler', () => {
const crawlerEl = containerEl.querySelector(constants.SELECTOR_BOX_PREVIEW_CRAWLER_WRAPPER);
ui.hideLoadingIndicator();
expect(crawlerEl).to.not.have.class(constants.CLASS_HIDDEN);
});
});
});

Expand Down
2 changes: 2 additions & 0 deletions src/lib/viewers/media/VideoBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const CLASS_PLAY_BUTTON = 'bp-media-play-button';
pauseHandler() {
super.pauseHandler();
this.showPlayButton();
this.hideLoadingIcon();
}

/**
Expand All @@ -111,6 +112,7 @@ const CLASS_PLAY_BUTTON = 'bp-media-play-button';
waitingHandler() {
if (this.containerEl) {
this.containerEl.classList.add(CLASS_IS_BUFFERING);
this.hidePlayButton();
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/lib/viewers/media/__tests__/VideoBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,29 @@ describe('lib/viewers/media/VideoBaseViewer', () => {

expect(videoBase.showPlayButton).to.be.called;
});

it('should hide the loading icon', () => {
sandbox.stub(videoBase, 'hideLoadingIcon');
videoBase.loadeddataHandler(); // load media controls UI

videoBase.pauseHandler();

expect(videoBase.hideLoadingIcon).to.be.called;
});
});

describe('waitingHandler()', () => {
it('should add the buffering class', () => {
videoBase.waitingHandler();
expect(videoBase.containerEl.classList.contains('bp-is-buffering'));
});

it('should hide the play button', () => {
sandbox.stub(videoBase, 'hidePlayButton');

videoBase.waitingHandler();
expect(videoBase.hidePlayButton).to.be.called;
});
});

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

0 comments on commit 800692d

Please sign in to comment.