vjs-video icon indicating copy to clipboard operation
vjs-video copied to clipboard

Runtime Properties

Open howardkitto opened this issue 9 years ago • 8 comments

This directive is great! It saved me so much time.

I need to log information about HLS playback quality. What is the best way for me to display the video.js runtime properties for example player.hls.segmentXhrTime, player.hls.bandwidth, player.hls.bytesReceived while the video is playing?

Huge thanks

howardkitto avatar Dec 12 '15 09:12 howardkitto

Hi @howardkitto, glad to see it's helpful.

To get a reference to runtime properties you can listen for the vjsVideoReady event to fire. Note that if you are managing more than one video you may need to add additional logic if (such as checking the id of the video) to determine which video the callback is handling. It should work something like the following from within the controller/directive the videos are invoked:

        scope.$on('vjsVideoReady', function (e, data) {
            //data contains `id` and `vid`
            console.log('e.data.vid:', data.id);
            console.log('e.data.vid:', data.vid);
            console.log('e.data.vid:', data.vid.player());
        });

For more information, check out this section of the README. Let me know if that helps/solves your problem!

ghost avatar Dec 12 '15 15:12 ghost

Thanks so much, this helps a lot however I can't figure out how to get at the hls runtime data or even find any examples!

howardkitto avatar Dec 13 '15 12:12 howardkitto

@howardkitto are you using this?

If so you_should_ be able to access the hls data like so (although I haven't tested using hls data myself):

scope.$on('vjsVideoReady', function (e, data) {
     //data contains `id` and `vid`
     console.log('e.data.vid:', data.vid.player().hls.segmentXhrTime);
});

ghost avatar Dec 13 '15 13:12 ghost

Yes that's exactly what I tried first of all but I get:

e.data.vid: undefined

howardkitto avatar Dec 13 '15 14:12 howardkitto

Looks like I had a typo there, it shouldn't be e.data.vid but data.vid! I'll pudeste the docs!

ghost avatar Dec 13 '15 16:12 ghost

Looks like if you copied the code the e.dva.vid is just the comment, are you getting a non null value for the data.vid variable?

ghost avatar Dec 13 '15 17:12 ghost

Hey Lonny

I'm pretty new to Angular, so some of this is black magic to me! In Test A I have this:

  • var app = angular.module('videoPlayer', ['vjs.video']);*
  •        app.controller('swapSource', ['$scope', function(scope) {*
    
  •         scope.$on('vjsVideoReady', function (e, data) {*
    
  •         console.log('data.vid:', data.vid.player());*
    
  •    });*
    

and I console logs this:

data.vid: Player {player: Player, options_: Object, id_: "vjs_video_3", name_: null, children_: Array[8]…}_

All good.

In Test B I have this:

  • var app = angular.module('videoPlayer', ['vjs.video']);*

    •        app.controller('swapSource', ['$scope', function(scope) {*
      
  •         scope.$on('vjsVideoReady', function (e, data) {*
    
  •         console.log('data.vid:',
    

    data.vid.player().hls.segmentXhrTime);*

  •    }); *
    

and when the page loads I get this...

TypeError: Cannot read property 'segmentXhrTime' of undefined

and this when I load the video:

data.vid: undefined

But the video plays with no problem

My guess is that I need to listen for some other event to fire, like when the segments are downloaded, but I can't find out what that might be. I put a question on Stackoverflow http://stackoverflow.com/questions/34252325/video-js-hls-runtime-properties but haven't got any answers yet

Thanks so much for your help so far!

Howard

On 13 December 2015 at 17:37, Lonny Gomes [email protected] wrote:

Looks like if you copied the code the e.dva.vid is just the comment, are you getting a non null value for the data.vid variable?

— Reply to this email directly or view it on GitHub https://github.com/LonnyGomes/vjs-video/issues/21#issuecomment-164279394 .

howardkitto avatar Dec 14 '15 13:12 howardkitto

@howardkitto Out of curiosity, is this only an issue when used with the directive? If so I wonder if there is an issue with how the video.js hls plugin is getting initialized.

ghost avatar Dec 16 '15 11:12 ghost