Skip to content

Commit

Permalink
Fix: Support disabling DASH viewer in DASH-supported environment (#140)
Browse files Browse the repository at this point in the history
Right now, if a user with a DASH-compatible browser disables the DASH viewer, then they cannot view any videos since the current X-Rep-Hints scheme hints to return either dash or mp4 reps, but not both. To fix this, this change updates the X-Rep-Hints sent to only send the mp4 (no filmstrip) when either the browser doesn't support DASH or if the DASH viewer is disabled.
  • Loading branch information
tonyjin committed May 26, 2017
1 parent e322c6a commit b292666
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,9 @@ const PREVIEW_LOCATION = findScriptLocation(PREVIEW_SCRIPT_NAME, document.curren
* @return {Object} Headers
*/
getRequestHeaders(token) {
const videoHint = Browser.canPlayDash() ? X_REP_HINT_VIDEO_DASH : X_REP_HINT_VIDEO_MP4;
const videoHint = Browser.canPlayDash() && !this.disabledViewers.Dash
? X_REP_HINT_VIDEO_DASH
: X_REP_HINT_VIDEO_MP4;
const headers = {
'X-Rep-Hints': `${X_REP_HINT_BASE}${X_REP_HINT_DOC_THUMBNAIL}${X_REP_HINT_IMAGE}${videoHint}`
};
Expand Down
9 changes: 9 additions & 0 deletions src/lib/__tests__/Preview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,15 @@ describe('lib/Preview', () => {
preview.getRequestHeaders();
expect(stubs.getHeaders).to.be.calledWith(stubs.headers, 'previewtoken', 'link', 'Passw0rd!');
});

it('should not add dash hints if the browser supports dash but dash is disabled', () => {
stubs.canPlayDash.returns(true);
preview.disabledViewers.Dash = 1;
stubs.headers['X-Rep-Hints'] += '[mp4]';

preview.getRequestHeaders();
expect(stubs.getHeaders).to.be.calledWith(stubs.headers, 'previewtoken', 'link', 'Passw0rd!');
});
});

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

0 comments on commit b292666

Please sign in to comment.