1
我正在使用videojs。它是自我托管的,并获得视频,它使http命中。 有我认为哪些与src一起的认证。 我收到的状态码是401.如何打印用户可以理解的错误信息。错误代码为401时Videojs自定义错误消息
目前我正在收到“无法加载视频,无论是因为服务器还是网络发生故障,或者因为格式不受支持。” 。但我想按照状态码显示错误。
需要帮助。
在此先感谢
我正在使用videojs。它是自我托管的,并获得视频,它使http命中。 有我认为哪些与src一起的认证。 我收到的状态码是401.如何打印用户可以理解的错误信息。错误代码为401时Videojs自定义错误消息
目前我正在收到“无法加载视频,无论是因为服务器还是网络发生故障,或者因为格式不受支持。” 。但我想按照状态码显示错误。
需要帮助。
在此先感谢
你可以尝试使用XMLHTTP请求头(视频错误之后),以捕获特定的HTTP状态代码...
function getError(url, callback)
{
var xhr = new XMLHttpRequest();
xhr.open('HEAD', url);
xhr.onreadystatechange = function() {
if (this.readyState == this.DONE) {
callback(this.status);
}
};
xhr.send();
}
/* after your video throws an error, try a simple head request */
getError("https://your.domain.com/video/sample.mp4", function(status) {
/* handle specific codes here... */
console.log(status);
});