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

MediaPlayerEvents.BUFFER_EMPTY not triggering #1257

Closed
protoAdnan opened this issue Mar 17, 2016 · 3 comments
Closed

MediaPlayerEvents.BUFFER_EMPTY not triggering #1257

protoAdnan opened this issue Mar 17, 2016 · 3 comments
Assignees
Milestone

Comments

@protoAdnan
Copy link

Hi all,

I am trying to implement a dash player and track the rebuffering (stalling) events and bitrates during the video playback.

I tried to look for "MediaPlayerEvents.BUFFER_EMPTY" or just "bufferstalled" to track stalling events in the playback as:
player.on(dashjs.MediaPlayer.events.dashjs.BUFFER_EMPTY, function() {n_buff += 1;});

but apparently "MediaPlayerEvents.BUFFER_EMPTY" or "bufferstalled" never triggers even when the video stalls and console registers the stalling event.

I am able to track buffering events using "MediaPlayerEvents.LOG" or "log" events and checking for a "Stalling Buffer" substring in the string like:
player.on(dashjs.MediaPlayer.events.dashjs.LOG, function(event) {if ( event.message.indexOf("Stalling Buffer") > -1 ){n_buff += 1;}});

However, I was wondering why the first approach isn't working. We should be able to track event triggered by the dashjs scripts.

On the other hand, I was able to track the stalling events from player element using.
var waitTime; function playHandler() { console.log('Rebuffering for ' + (window.performance.now() - waitTime)); waitTime = NaN; element.removeEventListener(playHandler); } element.addEventListener('waiting', function() { waitTime = window.performance.now(); element.addEventListener('playing', playHandler); });

One more thing:
in the dash.all.debug.js I saw that there are 2 different instances and assignments of BUFFER_EMPTY.

  1. BUFFER_EMPTY = 'bufferstalled' in MediaPlayerEvents
  2. BUFFER_EMPTY = 'bufferStalled' in some other scope.

I am not sure what is happening here. If anyone can clear this up I would be extremely grateful.

Regards

@dsparacio
Copy link
Contributor

Thanks for adding the issue @protoAdnan . I will check this out very soon.

@dsparacio dsparacio added this to the 2.1.0 milestone Mar 17, 2016
@dsparacio dsparacio self-assigned this Mar 17, 2016
@protoAdnan
Copy link
Author

So I think the code is triggering 'bufferStateChanged' instead of 'bufferStalled' and in order for one to track the stalling event, they have to track the 'bufferStateChange' using function on() and then see if the state change was a 'bufferStalled' or 'bufferLoaded'.
I did it like this
player.on('bufferStateChanged', function(e){if (e.state == 'bufferStalled'){console.log(e)}})

Another important thing is that the public MediaPlayerEvents() class doesn't have anything related to 'bufferStateChange' event. So, one solution could be to just add a variable in the publicMediaPlayerEvents class which holds 'bufferStateChange'.

But I think the more reasonable solution would be to add specific handlers in response to 'bufferStateChange' event which in turn trigger 'bufferstalled' event from the public MediaPlayerEvents class. More specifically, we can add a call to eventBus.trigger and trigger the MediaPlayerEvents.BUFFER_EMPTY if the buffer state is found to be stalled. i.e.

in onBufferLevelStateChanged:
eventBus.trigger(_MediaPlayerEventsJs2['default'].BUFFER_EMPTY)

might need to flesh this out further

@dsparacio
Copy link
Contributor

Sorry for this totally unclear aspect of the code. Test solution now. I have added simple triggers for buffer empty and loaded with no payload and moved buffer change event into MediaPlayerEvents with JSDoc.

dsparacio pushed a commit to dsparacio/dash.js that referenced this issue Apr 5, 2016
… switch for FF Safari. Still testing on IEEdge… Chrome works well, Firefox on Mac works well.
dsparacio pushed a commit that referenced this issue Apr 5, 2016
Fix for issue #1257 and partial fix for #1033
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

2 participants