Network error management

Network error management

Page loading errors may happen when the player try to display a web page from an external server, for example when the server is not reachable or when the page could not be found...

The video player has an integrated error management system to recover from such errors.
The default behavior is to reload the failing page over and over. During the process, nothing but the video (if any) is displayed on screen.
It is possible to customize the process and display a local web page to inform the user that the service is not available right now.

Note that the error management does not cover web pages loaded into an <iframe>, only main pages.

Depending on your needs, you can customize the error management using one of the following methods:

The easy way

In the www folder, create a page named error-iframe.html containing apologies, a video game or whatever you want to tell to the audience...
This page will be automatically displayed in case of a loading error.
In the meantime, the video player will check the availability of the failing page and reload it when it is available.

Note that this error page is loaded into an <iframe>, so it is not possible to control the video player using the JavaScript API.

Example error-iframe.html:

<html>
    <head>
        <style>
            body {
                background-color: #000000;
                font-family: "Roboto";
            }
            div {
                width: 100%;
                height:100%;
                font-size: 40px;
                color: white;
                text-align: center;
                margin-top: 200px;
            }
        </style>
    </head>
    <body>
        <div>I'll be back...</div>
    </body>
</html>

The hard way

If you need to control the video player or you need implement your own behavior, it is possible to go a step further.
This method is intended to be used by experienced users and requires a lot of precautions...

In the www folder, create a page named error-handler.html.
This page is loaded as a main page (not in an <iframe>) when a loading error is detected. It makes it possible to control of video player using the JavaScript API.
Here is what the embedded page looks like:

Example error-handler.html:

<html>
    <head>
        <script src="internal/error-handler.js"></script>
        <style>
            body {
                margin: 0px;
            }
            iframe {
                position: fixed;
                top: 0;
                left: 0;
                bottom: 0;
                right: 0;
                width: 100%;
                height: 100%;
                border: none;
                margin: 0;
                padding: 0;
                overflow: hidden;
            }
        </style>
    </head>
    <body>
        <iframe id="useriframe"></iframe>
    </body>
</html>

As you can see, this page is calling a script called internal/error-handler.js which is embedded into the video player.
It is responsible of the following tasks:

  • polling the failing web page and reload it when it is available.
  • loading the previously defined error-iframe.html into the iframe useriframe.

If you don't need those features, you can remove the <script> and <iframe> tags and create a regular page.
If you only need the retry mechanism but not the iframe loading, you can remove the <iframe> and keep the <script>. In this case, the error-iframe.html will not be used at all.

The error-handler.html is loaded with some query parameters that gives hints about the error cause:

  • url: the URL that has failed to load.
  • description: a human readable description of the error.
  • status: optional HTTP status code.
  • error: error code (ERROR_HOST_LOOKUP, ERROR_UNSUPPORTED_AUTH_SCHEME, ERROR_AUTHENTICATION, ERROR_PROXY_AUTHENTICATION, ERROR_CONNECT, ERROR_TIMEOUT, ERROR_TIMEOUT, ERROR_REDIRECT_LOOP, ERROR_UNSUPPORTED_SCHEME, ERROR_FAILED_SSL_HANDSHAKE, ERROR_BAD_URL, ERROR_FILE, ERROR_FILE_NOT_FOUND, ERROR_FILE_NOT_FOUND, ERROR_TOO_MANY_REQUESTS, ERROR_HTTP, ERROR_UNKNOWN)

Please don't try to load an external web page from the error page as it may end up calling the error page again and again if the external page is not reachable.