Skip to content

"end" event never fired when playing a stream #900

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

Closed
tbessie opened this issue Feb 7, 2018 · 5 comments
Closed

"end" event never fired when playing a stream #900

tbessie opened this issue Feb 7, 2018 · 5 comments

Comments

@tbessie
Copy link

tbessie commented Feb 7, 2018

When I'm playing a stream, the "end" event is never fired:

var player = new $wnd.Howl({
    src: url,
    html5: true, // A live stream can only be played through HTML5 Audio.
    format: ['webm', 'opus', 'mp3', 'aac'],
    autoplay: false
});

player.on('end', function(id) {
    console.log('ended!');
});

player.play();

I never get the "end" event. The URL provided points to a servlet on my server; the servlet is properly closing the output stream when it's done streaming content, so Howler should be noticing the stream has been closed.

@tbessie
Copy link
Author

tbessie commented Feb 7, 2018

I found out what the issue is; if the file (webm/opus in this case) doesn't contain any duration information, I never get the "end" event. If it does, I do.

This leads me to believe that Howler is using the duration information in the audio file header to determine when the audio ends, as opposed to when it reaches the end of file/buffers. This isn't the best way of determining this - Howler should notice when there is no more data to stream (socket is closed, for instance, or last buffer is played) in order to know when the playback has ended, instead of using a timer set to the duration that the file SAYS it is.

Any chance you can fix this? It's a bit tricky to do, from what I've found - I was trying to do this myself, by allocating a set of buffers as the data is streamed, and then decoding them one at a time whenever a given buffer is done playing, and directing the browser to play the next buffer, until the last buffer is done. It's non-trival to do this, so I can understand why this wasn't done in Howler. However, it seems to me to be a better method rather than depending on the duration in the audio file header.

What do you think, @goldfire ?

@tbessie
Copy link
Author

tbessie commented Feb 9, 2018 via email

@goldfire
Copy link
Owner

goldfire commented Feb 9, 2018

@tbessie This was closed automatically because I marked it was fixed in commit 51508c8.

@tbessie
Copy link
Author

tbessie commented Feb 10, 2018

Ah, thanks for explaining. I didn't realize you'd fixed it.

@goldfire
Copy link
Owner

It may not handle your specific scenario, so let me know if you are still seeing the issue and I'll reopen.

ringcrl pushed a commit to ringcrl/howler.js that referenced this issue Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants