You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
BUFFER_EMPTY = 'bufferstalled' in MediaPlayerEvents
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
The text was updated successfully, but these errors were encountered:
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)
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
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.
I am not sure what is happening here. If anyone can clear this up I would be extremely grateful.
Regards
The text was updated successfully, but these errors were encountered: