Skip to content
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

Issue when changing sources in an ended event #2650

Closed
fxthomas opened this issue Jun 13, 2019 · 6 comments
Closed

Issue when changing sources in an ended event #2650

fxthomas opened this issue Jun 13, 2019 · 6 comments

Comments

@fxthomas
Copy link

fxthomas commented Jun 13, 2019

Hello all,

We've been hitting a strange issue with the latest MediaElement.js (4.2.10) at airsonic/airsonic#1080 that we can't seem to resolve, and we'd appreciate some help.

The following sequence of events seems to work for HTML5 MediaElement, but not with MediaElement.js. For me, this fails in Firefox (67/68) only, not on Chromium (75).

  1. Set src, then call load() and play() for a first MP3 stream.
  2. In the ended event handler, do the same for a second MP3 stream.

Step 2 appears to buffer the second stream correctly, but playback never starts, and the console shows AbortError: The fetching process for the media resource was aborted by the user agent at the user's request.:

Screenshot from 2019-06-13 20-50-22

I've managed to put together a short reproduction case at https://github.com/fxthomas/mediaelement-test-aborterror.

@fxthomas
Copy link
Author

fxthomas commented Jun 23, 2019

I think I've managed to track down the root cause of this issue. I updated the test repo with some more info about it!

The root cause appears to be a call to player.pause() in one of the handlers for the ended event.

@karawitan karawitan added this to the 4.2.11 milestone Jun 24, 2019
fxthomas added a commit to fxthomas/airsonic that referenced this issue Jul 2, 2019
This commit works around a race caused by some of our JS code trying to
run play() for the next song while the MEJS player is still cleaning up
the last song.

MEJS issue: mediaelement/mediaelement#2650
@fxthomas
Copy link
Author

fxthomas commented Jul 8, 2019

I've dug a bit into it, and managed to track the introduction of that particular pause call back to 33080d6 (yup, that's old). That does not tell me a lot, unfortunately...

It seems that calling pause() should be unnecessary when we're in the ended event (the stream should have already finished playing), but maybe I'm missing something.

Is it possibly needed by a renderer (in which case, which one?) or does it trigger UI updates (in which case, can we decouple them from calls to pause())?

I'll continue to dig, maybe I'll find something.

@karawitan
Copy link
Collaborator

Any success with this one ?

eharris pushed a commit to eharris/airsonic that referenced this issue Sep 10, 2019
This commit works around a race caused by some of our JS code trying to
run play() for the next song while the MEJS player is still cleaning up
the last song.

MEJS issue: mediaelement/mediaelement#2650
@karawitan karawitan removed this from the 4.2.11 milestone Sep 15, 2019
@fxthomas
Copy link
Author

Well, holidays prevented me from working on this, but I'm back 😉

After doing some more investigation in the internals of the MEJS player, I found out that our (in Airsonic) initialization order was a bit unusual. In particular, we were adding events to the MEJS player before it was fully initialized, and our event handlers were carried over once MEJS had finished its full initialization.

I believe that airsonic/airsonic#1254 fixes the issue completely on our side, and I'm not certain it should even be considered a bug on MEJS's part (since technically we were using it somewhat wrong).

@jvoisin
Copy link

jvoisin commented Sep 21, 2019

It might be detecting added event handling during initialization to warn that something is wrong, or at least document it somewhere :)

@karawitan
Copy link
Collaborator

Ok IIUC, there is no issue in MediaElement ... closing ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants