Skip to content

Commit

Permalink
Upgrade: Upgrade Shaka-player to 2.1.1 (#110)
Browse files Browse the repository at this point in the history
Changes here: https://github.com/google/shaka-player/releases
Notably, the upgrade adds support for asynchronous response filters,
which can be used for handling when the token is expired. This commit
also modifies DashViewer to use the new player API (getVariantTracks and
getTextTracks), instead of the deprecated getTracks and selectTrack
methods
  • Loading branch information
bhh1988 authored May 11, 2017
1 parent b4c8d32 commit 4387245
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const webpackConfig = require('./webpack.karma.config');

const DOC_STATIC_ASSETS_VERSION = '0.121.1';
const MEDIA_STATIC_ASSETS_VERSION = '0.120.1';
const MEDIA_STATIC_ASSETS_VERSION = '0.122.0';
const MODEL3D_STATIC_ASSETS_VERSION = '0.115.0';
const SWF_STATIC_ASSETS_VERSION = '0.112.0';
const TEXT_STATIC_ASSETS_VERSION = '0.114.0';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const X_REP_HINT_VIDEO_MP4 = '[mp4]';
// These should be updated to match the Preview version in package.json
// whenever a file in that third party directory is updated
export const DOC_STATIC_ASSETS_VERSION = '0.121.1';
export const MEDIA_STATIC_ASSETS_VERSION = '0.120.1';
export const MEDIA_STATIC_ASSETS_VERSION = '0.122.0';
export const MODEL3D_STATIC_ASSETS_VERSION = '0.115.0';
export const SWF_STATIC_ASSETS_VERSION = '0.112.0';
export const TEXT_STATIC_ASSETS_VERSION = '0.114.0';
Expand Down
8 changes: 4 additions & 4 deletions src/lib/viewers/media/DashViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class DashViewer extends VideoBaseViewer {
* @return {Object|undefined}
*/
getActiveTrack() {
const tracks = this.player.getTracks();
const tracks = this.player.getVariantTracks();
return tracks.find((track) => track.active);
}

Expand All @@ -191,7 +191,7 @@ class DashViewer extends VideoBaseViewer {
*/
enableHD() {
this.showLoadingIcon(this.hdRepresentation.id);
this.player.selectTrack(this.hdRepresentation, true);
this.player.selectVariantTrack(this.hdRepresentation, true);
}

/**
Expand All @@ -202,7 +202,7 @@ class DashViewer extends VideoBaseViewer {
*/
enableSD() {
this.showLoadingIcon(this.sdRepresentation.id);
this.player.selectTrack(this.sdRepresentation, true);
this.player.selectVariantTrack(this.sdRepresentation, true);
}

/**
Expand Down Expand Up @@ -332,7 +332,7 @@ class DashViewer extends VideoBaseViewer {
* @return {void}
*/
calculateVideoDimensions() {
const tracks = this.player.getTracks();
const tracks = this.player.getVariantTracks();

// Iterate over all available video representations and find the one that
// seems the biggest so that the video player is set to the max size
Expand Down
12 changes: 6 additions & 6 deletions src/lib/viewers/media/__tests__/DashViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ describe('lib/viewers/media/DashViewer', () => {
destroy: () => {},
getNetworkingEngine: sandbox.stub().returns(stubs.networkEngine),
getStats: () => {},
getTracks: () => {},
getVariantTracks: () => {},
load: () => {},
selectTrack: () => {}
selectVariantTrack: () => {}
};
stubs.mockPlayer = sandbox.mock(dash.player);

Expand Down Expand Up @@ -207,7 +207,7 @@ describe('lib/viewers/media/DashViewer', () => {
it('should get active track', () => {
stubs.inactive = { active: false };
stubs.active = { active: true };
stubs.mockPlayer.expects('getTracks').returns([stubs.inactive, stubs.active]);
stubs.mockPlayer.expects('getVariantTracks').returns([stubs.inactive, stubs.active]);
expect(dash.getActiveTrack()).to.equal(stubs.active);
});
});
Expand All @@ -230,7 +230,7 @@ describe('lib/viewers/media/DashViewer', () => {
it('should enable HD video for the file', () => {
dash.hdRepresentation = { id: '1' };
sandbox.stub(dash, 'showLoadingIcon');
stubs.mockPlayer.expects('selectTrack').withArgs(dash.hdRepresentation, true);
stubs.mockPlayer.expects('selectVariantTrack').withArgs(dash.hdRepresentation, true);
dash.enableHD();
expect(dash.showLoadingIcon).to.be.calledWith('1');
});
Expand All @@ -240,7 +240,7 @@ describe('lib/viewers/media/DashViewer', () => {
it('should enable SD video for the file', () => {
dash.sdRepresentation = { id: '1' };
sandbox.stub(dash, 'showLoadingIcon');
stubs.mockPlayer.expects('selectTrack').withArgs(dash.sdRepresentation, true);
stubs.mockPlayer.expects('selectVariantTrack').withArgs(dash.sdRepresentation, true);
dash.enableSD();
expect(dash.showLoadingIcon).to.be.calledWith('1');
});
Expand Down Expand Up @@ -444,7 +444,7 @@ describe('lib/viewers/media/DashViewer', () => {

describe('calculateVideoDimensions()', () => {
it('should calculate the video dimensions based on the reps', () => {
stubs.mockPlayer.expects('getTracks').returns([{ width: 200 }, { width: 100 }]);
stubs.mockPlayer.expects('getVariantTracks').returns([{ width: 200 }, { width: 100 }]);
dash.calculateVideoDimensions();
expect(dash.hdRepresentation.width).to.equal(200);
expect(dash.sdRepresentation.width).to.equal(100);
Expand Down
Loading

0 comments on commit 4387245

Please sign in to comment.