Anna Melzer
Anna Melzer

Reputation: 1613

Show jwplayer buffer on console

I am trying to debug one of my aplications, and I am trying to get the current buffer printed to console. However, this only returns "undefined".

jwplayer('video-wrp2').setup({
    "flashplayer": JWPLAYER,
    "file": VIDEO1,
    "skin": PLAYER_SKIN,
    "width": 1000,
    "height": 568,
    "controlbar": "none",
    "autostart":true,
    "image":IMAGE1,
     events:{
        onBufferChange: function(e) {
                console.log(e.buffer);
            }
        }
    }); 

What is the right way to do it? Thanks in advance

Upvotes: 2

Views: 5536

Answers (3)

Ben
Ben

Reputation: 885

If you're using JWPlayer 6, change your code to

jwplayer('video-wrp2').setup({ file: VIDEO1, skin: PLAYER_SKIN, width: 1000, height: 568, autostart:true, image:IMAGE1, debug: true });

Maybe it will work also in JWPlayer 5.

Example : http://jsfiddle.net/hiteshbhilai2010/YgjYW/7/

Upvotes: 2

emaxsaun
emaxsaun

Reputation: 4201

The issue is that:

callback.buffer - Does not exist. Which is why it is saying undefined.

So this call will not work:

console.log(callback.buffer);

However, this call works fine:

getBuffer();

So this console.log command will work just fine:

console.log(jwplayer('playerwnqZpIQLUFAE').getBuffer());

Upvotes: 0

Hitesh
Hitesh

Reputation: 4298

I am not sure what is wrong here, but it does shows undefined.I too tried and I am also getting undefined However, you can use other method getbuffer(). Source :Jwplayer API and javascript-api-reference

jwplayer('playerwnqZpIQLUFAE').setup({
        file: 'http://www.youtube.com/watch?v=abjAqvdGZgM',
        image: 'https://www.longtailvideo.com/content/images/jw-player/lWMJeVvV-876.jpg',
        width: '100%',
        stretching : 'exactfit',
        aspectratio: '4:3',
        fallback: 'false',
        primary: 'HTML5',
        events:{
        onBufferChange: function(callback) {
                console.log(callback.buffer);
                console.log(jwplayer('playerwnqZpIQLUFAE').getBuffer());
            }
        }
    });

: JSFIDDLE LINK

This is working and i can see the buffer progress.

Upvotes: 1

Related Questions