Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FEC-10817): expose the current time of the video element in live streams #156

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
dan-ziv marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* 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