Hey,
I've been using videojs for quite a while, and everything works absolutely great. My only issue is that I fail to disable videoJs from printing error logs (actually, I would like to disable any log issued by videoJs).
For example, if I try to load an unsupported source, the following error is always printed:
logger.js:21 VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported.
You may get the same behavior here:
http://jsbin.com/waqisijugi/1/edit?html,output
Hiding the the UI on top of the video element was pretty easy (using CSS), but I couldn't find any way to disable the console's error message.
Is there a way to do that? I looked in the documentation as well, but couldn't find any way to achieve this.
Thanks a lot!
I would like to disable those messages from being printed to the console.
The logs messages are being printed to the console.
5.12.5
Chrome
Linux
none
Thanks in advance,
Roee.
I would suggest not using CSS to hide the error dialog. Rather, you can stop it from intercepting error events:
var player = videojs('my-player');
var errorDisplay = player.getChild('errorDisplay');
errorDisplay.off(player, 'error', errorDisplay.open);
That will disable the error display entirely. You could then write your own logic tied to the player's error event that will open the error display only on certain errors:
errorDisplay.on(player, 'error', function(e) {
var error = player.error();
// Only open the errorDisplay for errors that are not "MEDIA_ERR_SRC_NOT_SUPPORTED"
if (error && error.code !== 4) {
errorDisplay.open();
}
});
Second, disabling the logs is not possible in any _official_ manner, but it's a feature I've wanted to implement for a while (if you'd like to take a stab at adding that feature, go for it!). The _untested/unofficial_ way to disable logs would be to override them with no-op functions. Something like:
videojs.log = function() {};
videojs.log.error = videojs.log.warn = videojs.log;
That will silence _all_ logging from Video.js. But, again, this is an _untested/unofficial_ way to achieve the effect you want.
Another option to disable the error dialog is just say you don't want it:
var player = videojs("my-player", {
errorDisplay: false
});
As for the logging, we've been wanting loglevels for a while now.
Thanks a lot for both of you, @gkatsev @misteroneill !!
I'll disable the error dialog using the suggested way, as it seems preferable over CSS.
I couldn't find it in the docs though, is it missing or did I miss it?
Regarding log levels - I'll have a look at it soon, and I'll try to implement it myself :+1:
Thanks!!
It's not in the docs, no. It's not a common request, but knowing about passing options to child components and/or how Video.js component system works is always helpful. 馃憤
@Kasher a PR to add loglevel support would be amazing!
Looks like in Video.js v6 logs output to the console can be disabled with:
window.videojs.log.level('off');
Yes! That's true - sounds like this is a good candidate for closing now that we support it.
Most helpful comment
Looks like in Video.js v6 logs output to the console can be disabled with: