Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

http live streaming - Videojs HLS stream, absolute stream time

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...