Skip to content

Commit

Permalink
feat(FEC-10817): expose the current time of the video element in live…
Browse files Browse the repository at this point in the history
… streams (#156)
  • Loading branch information
Dan Ziv authored Jun 17, 2021
1 parent bb6c018 commit c298892
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
bytes: response.data.byteLength,
url: response.uri
});
if (this.isLive()) {
this._videoElement.dispatchEvent(new window.Event(EventType.DURATION_CHANGE));
}
break;
case shaka.net.NetworkingEngine.RequestType.MANIFEST:
this._parseManifest(response.data);
Expand Down Expand Up @@ -1158,6 +1161,28 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
return false;
}

/**
* Gets the segment duration of the stream
* @return {number} - Segment duration in seconds
*/
get liveDuration() {
return this._getLiveEdge();
}

/**
* Gets the live duration
* @return {number} - live duration
*/
getSegmentDuration(): number {
if (this._shaka) {
const manifest = this._shaka.getManifest();
if (manifest && manifest.presentationTimeline) {
return manifest.presentationTimeline.getMaxSegmentDuration();
}
}
return 0;
}

/**
* An handler to shaka adaptation event
* @function _onAdaptation
Expand Down Expand Up @@ -1265,9 +1290,8 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
getStartTimeOfDvrWindow(): number {
if (this.isLive() && this._shaka) {
return this._shaka.seekRange().start;
} else {
return 0;
}
return 0;
}

/**
Expand Down

0 comments on commit c298892

Please sign in to comment.