goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
23.98k stars 2.23k forks source link

FireFox stream stoped #883

Closed amirping closed 6 years ago

amirping commented 6 years ago

i use howler to play stream from URL . it work correctly on chrome , but with Firefox the stream auto stop after few seconds ( about 20s ) .

  this.sound = new Howl({
      src: [streamUrl],
      html5: true,
      autoplay : true, // try to fix 
      format: ['mp3'] // try to fix 
});

on chrome it work even without the autoplay and the format option . Firefox Quantom 57.0.2

asaivan commented 6 years ago

I have had the same issue. Trying to get it working on FF 57. Stops after 1 second with no errors.

roks0n commented 6 years ago

Having the same issue, these are my settings:

radio = new Howl({
    src: stations[currentStation].stream,
    html5: true,
    format: ['mp3'],
    volume: volume,
});
radio.play();

It stops streaming the file after a few seconds. I'm currently using howler v2.0.4 in FF 57.0.1. Will update it and see if it works on the latest one. I'm not seeing any errors/warnings in the console.

Update 1: Also broken on howler v2.0.7. Update 2: I did some digging and noticed that when the sound stops playing the onend function is called. I wasn't able (yet) to figure out what exactly causes this.

trvbr commented 6 years ago

This is happening for us as well.

Test it here: https://jsfiddle.net/trvbr/guw1uu1L

SoundManager2 works in the same Firefox environment. Check out his (Scott Schiller's) code for pointers? Maybe there is a hack in there that fixes it.

amirping commented 6 years ago

@roks0n yes i noticed that , i think it's problem with buffer or some think like that since the onend function is called when the media end .

goldfire commented 6 years ago

Interesting, I wonder when this change was made in Firefox. Unless I'm missing something, it looks like the only way to fix this is to listen to the durationchange event and re-create the ended timer with the difference in duration added on. This feels really hacky though. Has anyone found any other way to detect if a stream is being played in Firefox (the duration of Infinity was being relied upon previously)?

AlteranAncient commented 6 years ago

I've just been bitten by this as well. I made the leap from Chrome to Quantum a few weeks ago, and I've noticed some odd behaviour specific to the current version of Firefox:

I realise you're probably not that interested in SM2 itself, but I think that it is probably helpful to know that Firefox may not be handling streams with OGG extensions correctly - and that it might not be specific to Howler.

ntavelis commented 6 years ago

I have the same issue, using the version 2.0.5 solves this problem. So a change must have been made after this version.

kenger commented 6 years ago

Yeah, I can confirm that works. Versions 2.0.7 and 2.0.8 have the problem, i dont know for version 2.0.6 but version 2.0.5 is working.

ntavelis commented 6 years ago

2.0.6 has the same issue.

mmavko commented 6 years ago

same issue here. jsfiddle: https://jsfiddle.net/guw1uu1L/3/

playback stops after some 5 seconds (Chrome 64, Mac OS, Ubuntu).

update: Chrome itself can't play this file either. navigate directly to https://storage.googleapis.com/aloud-145812.appspot.com/344669%2Fmp3%2Farticle-344669.mp3 and playback will similarly stop. Firefox is OK. Looks like it's Chrome 64 problem.

goldfire commented 6 years ago

The reason it "works" in 2.0.5 is because it is broken. The ended event is still getting fired, but since the sound is still playing, howler goes into an infinite timeout loop checking for it to be over. The addition of a time check relative to the reported duration causes it to end at the correct time (https://github.com/goldfire/howler.js/commit/ee3d0aed9bc9879742b9cc4bac069c9b494f7fa7). Since it is a stream, the duration should be reported as Infinity, but for some reason, Firefox is reporting an incorrect duration value.

kenger commented 6 years ago

Usage of an html5 audio element show the strange behavior of Firefox. An audio element with my live stream source has an increasing duration instead of a positive Infinite as specified by the html5 spec.

I dont know if this is a problem with my server (ICEcast) metadata or Firefox. I dont understand how firefox should know if an mp3 is a live or not.