Skip to content

Commit

Permalink
feat: change media (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv authored and OrenMe committed Oct 16, 2017
1 parent 47d77af commit 4382852
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 57 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"karma-webpack": "^2.0.2",
"mocha": "^3.2.0",
"mocha-cli": "^1.0.1",
"playkit-js": "git+https://github.com/kaltura/playkit-js.git#v0.10.0",
"playkit-js": "git+https://github.com/kaltura/playkit-js.git#v0.12.0",
"shaka-player": "2.2.2",
"sinon": "^2.0.0",
"sinon-chai": "^2.8.0",
Expand All @@ -73,7 +73,7 @@
"keywords": [],
"license": "AGPL-3.0",
"peerDependencies": {
"playkit-js": "git+https://github.com/kaltura/playkit-js.git#v0.10.0",
"playkit-js": "git+https://github.com/kaltura/playkit-js.git#v0.12.0",
"shaka-player": "2.2.2"
},
"repository": {
Expand Down
33 changes: 17 additions & 16 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,25 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
}

/**
* Destroying the dash adapter
* Destroys the dash adapter
* @function destroy
* @override
*/
destroy(): void {
DashAdapter._logger.debug('destroy');
super.destroy();
this._loadPromise = null;
this._sourceObj = null;
this._buffering = false;
if (this._shaka) {
this._removeBindings();
this._shaka.destroy();
}
if (DashAdapter._drmProtocol) {
DashAdapter._drmProtocol.destroy();
DashAdapter._drmProtocol = null;
}
* @returns {Promise<*>} - The destroy promise.
*/
destroy(): Promise<*> {
return super.destroy().then(() => {
DashAdapter._logger.debug('destroy');
this._loadPromise = null;
this._buffering = false;
if (DashAdapter._drmProtocol) {
DashAdapter._drmProtocol.destroy();
DashAdapter._drmProtocol = null;
}
if (this._shaka) {
this._removeBindings();
return this._shaka.destroy();
}
});
}

/**
Expand Down
102 changes: 63 additions & 39 deletions test/src/dash-adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,25 @@ describe('DashAdapter: load', () => {
config = {playback: {options: {html5: {dash: {}}}}};
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
TestUtils.removeVideoElementsFromTestPage();
});

it('should create all dash adapter properties', () => {
it('should create all dash adapter properties', (done) => {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
dashInstance.load().then(() => {
dashInstance._shaka.should.exist;
dashInstance._config.should.exist;
dashInstance._videoElement.should.exist;
dashInstance._sourceObj.should.exist;
done();
});
});

Expand Down Expand Up @@ -214,12 +217,13 @@ describe('DashAdapter: destroy', () => {
dashInstance._sourceObj.should.be.exist;
dashInstance._config.should.be.exist;
dashInstance._buffering = true;
dashInstance.destroy();
(!dashInstance._loadPromise).should.be.true;
(!dashInstance._sourceObj).should.be.true;
(!dashInstance._config).should.be.true;
dashInstance.destroy().then(() => {
(!dashInstance._loadPromise).should.be.true;
(!dashInstance._sourceObj).should.be.true;
(!dashInstance._config).should.be.true;
dashInstance._buffering.should.be.false;
done();
done();
});
});
});
});
Expand All @@ -233,9 +237,11 @@ describe('DashAdapter: _getParsedTracks', () => {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -288,9 +294,11 @@ describe('DashAdapter: selectVideoTrack', () => {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -407,9 +415,11 @@ describe('DashAdapter: selectAudioTrack', () => {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -499,9 +509,11 @@ describe('DashAdapter: selectTextTrack', () => {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -615,9 +627,11 @@ describe('DashAdapter: enableAdaptiveBitrate', () => {
dashInstance = DashAdapter.createAdapter(video, vodSource, config);
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -663,9 +677,11 @@ describe('DashAdapter: isLive', () => {
config = {playback: {options: {html5: {dash: {}}}}};
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -710,9 +726,11 @@ describe('DashAdapter: seekToLiveEdge', () => {
config = {playback: {options: {html5: {dash: {}}}}};
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -750,9 +768,11 @@ describe('DashAdapter: get currentTime', () => {
config = {playback: {options: {html5: {dash: {}}}}};
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -798,9 +818,11 @@ describe('DashAdapter: set currentTime', () => {
config = {playback: {options: {html5: {dash: {}}}}};
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down Expand Up @@ -846,9 +868,11 @@ describe('DashAdapter: get duration', () => {
config = {playback: {options: {html5: {dash: {}}}}};
});

afterEach(() => {
dashInstance.destroy();
dashInstance = null;
afterEach((done) => {
dashInstance.destroy().then(() => {
dashInstance = null;
done();
});
});

after(() => {
Expand Down

0 comments on commit 4382852

Please sign in to comment.