I need to know at a given time what is the absolute time of a HLS stream, and not the relative time (relative to when I opened the player).
For example
- stream starts at 14:00 (the server starts broadcasting)
- user 1 open videojs at 14:00 => absolute time = 0
- user 2 open videojs at 14:07 => absolute time = 7
I have a snippet that kinds of work but I'm not sure if it's the best way to do it or even if it will work reliably in every contexts ??:
const vhs = player.tech().vhs;
const segments = vhs.playlists.media().segments;
const lastSegment = segments[segments.length - 1];
if (lastSegment && lastSegment.videoTimingInfo) {
console.log("absolute time is :", lastSegment.videoTimingInfo.baseMediaDecodeTime);
}
Any feedback on this would be amazing
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…