0

I using player object. var player = videojs.getPlayer('videoplayer');

when console.log(player) it will be shows mediainfo object.

But when consolinging mediainfo name value it will return undefined. console.log(player.mediainfo.name);

I will expect to show name value.

B Developer2
  • 49
  • 2
  • 9

2 Answers2

0

I believe what you are seeing is the behavior of console.log() displaying undefined as its return value. You should see this even if you do

 >console.log('foo')
 foo
 undefined

This is explained in detail in Why does console.log say undefined, and then the correct value?

In comparison, you can also see that undefined is not printed if you just enter: player.mediainfo.name into the console. For example, this is the output on one of our sample players in our docs:

>player.mediainfo.name
"Displaying a Pre-Roll Ad in a Brightcove Player"

But you will see undefined after this using console.log()

>console.log(player.mediainfo.name)
Displaying a Pre-Roll Ad in a Brightcove Player
undefined
0

It sounds like you are trying to get mediainfo before it's populated. Once the player has loaded it then fetches the video from Brightcove's Playback API, then sets mediainfo and loads the video source. Try

player.on('loadstart', function() { console.log(player.mediainfo.name); });

misterben
  • 7,455
  • 2
  • 26
  • 47