Hls.js: Detect ended stream based on #EXT-X-ENDLIST

Created on 27 Jun 2019  Â·  7Comments  Â·  Source: video-dev/hls.js

What do you want to do with Hls.js?
Detect if the stream has been ended based on #EXT-X-ENDLIST in m3u8 file

What have you tried so far?
I've been output all Events with console, but there are no Events fired when the stream has ended.

All 7 comments

The HTMLVideoElement#stalled event is fired when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.

const video = document.querySelector('video');

video.addEventListener('stalled', (event) => {
  console.log('ended');
});

You can't rely on the 'stalled' event with MSE.

The 'ended' event on the media element should be triggered if we are calling endOfStream() on the MediaSource. Maybe this isn't happening currently.

On 27 Jun 2019, at 16:12, Tomohiro IKEDA <[email protected]notifications@github.com> wrote:

The HTMLVideoElement#stalled event is fired when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.

const video = document.querySelector('video');

video.addEventListener('stalled', (event) => {
console.log('ended');
});

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/video-dev/hls.js/issues/2288?email_source=notifications&email_token=AAY34WJK4HDMECPTOUE3BVDP4TDD7A5CNFSM4H32RS72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYXH2YY#issuecomment-506363235, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAY34WNCK7Q32NO2Y5U2PVLP4TDD7ANCNFSM4H32RS7Q.

Correct me, ended event produce 2 possibilities:

  1. Video was over
  2. data is not available (due to lack of connection)

I don't think it should be fired in the second case, but don't have a laptop to check at the moment

On 28 Jun 2019, at 04:39, Meirza Arson <[email protected]notifications@github.com> wrote:

Correct me, ended event produce 2 possibilities:

  1. Video was over
  2. data is not available (due to lack of connection)

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/video-dev/hls.js/issues/2288?email_source=notifications&email_token=AAY34WJ6XI536RNMQHVD6EDP4V2VHA5CNFSM4H32RS72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYY4LIQ#issuecomment-506578338, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAY34WPL7JN5ZLPRYSGZKJDP4V2VHANCNFSM4H32RS7Q.

I think you're right @tjenkinson .

So i made script below:

const video = document.getElementById('video');
video.addEventListener('ended', (event) => {
  console.log('Stream ended.');
});

I tested the video running m3u8 with #EXT-X-ENDLIST and the log showing Stream ended as expected. BUT if there is no #EXT-X-ENDLIST, the log output is different.

Thanks for the discussion @tjenkinson @Korilakkuma.

We have an ended event listener on the video element, but when I received EXT-X-ENDLIST tag I see nothing happened... Also, I did try to lister for stalled event, also does not help. I did try to listen for Hls.Events.BUFFER_EOS but it's emmited only few seconds after EXT-X-ENDLIST received, so users see spinner in video element. How can I know that EXT-X-ENDLIST was received?

Hi @moonbrv,

The latest release includes some changes that should have improved handling of ENDLIST: https://github.com/video-dev/hls.js/pull/3124

Please file a new Bug Report as this issue was closed over a year ago.

Please include all the details required to reproduce your issue - hlsjs config, stream properties, etc...

( I have a guess that if your playlist update that adds EXT-X-ENDLIST does not also add a new segment, then EOS is never added because all appending was done in LIVE mode rather than VOD mode. That might not be the problem but something we can look into as part of a new issue. )

Was this page helpful?
0 / 5 - 0 ratings

Related issues

neuman picture neuman  Â·  4Comments

bharathsn0812 picture bharathsn0812  Â·  4Comments

nickcartery picture nickcartery  Â·  4Comments

krsvital picture krsvital  Â·  3Comments

NicholasAsimov picture NicholasAsimov  Â·  3Comments