Skip to content

Commit

Permalink
Merge pull request #66 from bbc/refresh-manifest-callback-smp-3
Browse files Browse the repository at this point in the history
add refreshManifest callback
  • Loading branch information
robertbryer authored Jul 24, 2020
2 parents 7d5594b + 0c4db78 commit bd522c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ declare namespace dashjs {
setSelectionModeForInitialTrack(mode: TrackSelectionMode): void;
getSelectionModeForInitialTrack(): TrackSelectionMode;
retrieveManifest(url: string, callback: (manifest: object | null, error: any) => void): void;
refreshManifest(callback: (manifest: object | null, error: any) => void): void;
addUTCTimingSource(schemeIdUri: string, value: string): void;
removeUTCTimingSource(schemeIdUri: string, value: string): void;
clearDefaultUTCTimingSources(): void;
Expand Down
15 changes: 14 additions & 1 deletion src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1722,9 +1722,22 @@ function MediaPlayer() {
* Reload the manifest that the player is currently using.
*
* @memberof module:MediaPlayer
* @param {function} callback - A Callback function provided when retrieving manifests
* @instance
*/
function refreshManifest() {
function refreshManifest(callback) {
let self = this;

const handler = function (e) {
if (!e.error) {
callback(e.manifest);
} else {
callback(null, e.error);
}
eventBus.off(Events.INTERNAL_MANIFEST_LOADED, handler, self);
};

eventBus.on(Events.INTERNAL_MANIFEST_LOADED, handler, self);
streamController.refreshManifest();
}

Expand Down

0 comments on commit bd522c6

Please sign in to comment.