Custom Media Time Range that hides unseekable part of the seekbar during Live DVR #746
-
This might be an odd question but it would really help my usecase. Since any seeking outside of the seekable range of 2 hours is invalid, I want a custom version of the media-time-range basically, that just hides whatever is before those 2 hours. I might even want to be able to change that to even a smaller seekable range than the 2 hours, lets say the last 30 minutes. The media-time-display would then be relative to the start of the custom time range, and the duration would then be a max of 2 hours. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Right now I think this might be tough to do with our current time range element, but there's work as part of a time range refactor that at least might make implementing some of this easier. One thought that comes to mind...would something like |
Beta Was this translation helpful? Give feedback.
-
It's a bit hacky but it gets the job done I think: https://codesandbox.io/s/media-chrome-offset-live-7nr2zf Object.defineProperty(timerange, "mediaSeekable", {
get() {
let desc = Object.getOwnPropertyDescriptor(
Object.getPrototypeOf(timerange),
"mediaSeekable"
);
return desc.get.call(this);
},
set(range) {
if (range == null) {
this.removeAttribute("mediaseekable");
return;
}
let [, end] = range;
// clamp to 20s from the end
range[0] = Math.max(0, end - 20);
console.log(range);
this.setAttribute("mediaseekable", range.join(":"));
}
}); The monkey patch overrides the mediaSeekable setter so seekable start is clamped 20s from the end for that live stream. |
Beta Was this translation helpful? Give feedback.
It's a bit hacky but it gets the job done I think: https://codesandbox.io/s/media-chrome-offset-live-7nr2zf