How to detect disconnected network?

Published 2015-01-15 | (Compatible with SDK 2.5,3.5,4.5,5.0,5.1 and 2011,2012,2013,2014 models)

Lead

Implementation tips for network disconnected event

The Smart TV policy requires that all network errors which disable application functions should be populated with proper message. This includes errors occurred while downloading some content or during Audio/Video playback. It is strongly recommended that not to rely on the OnNetworkDisconnected player event only, but rather to check periodically all available network interfaces.

Below, there is a sample code snippet on how to implement that.

Note

This example just guarantee till gateway connection, do not till internet network. If app should guarantee connection of internet network, app should communicate with app server whether TV connected on internet network or not.

Too frequent repeating may result in slowing down the application, too rare may not discover the network error before the playback is hanged. The recommended values are between 500 and 2000 milliseconds.

varnetworkPlugin=document.getElementById('pluginObjectNetwork');

varinternetConnectionInterval=500;//this is just an example value that repeats the connection check every 500 milliseconds

Add a handler function for showing and hiding the network disconnection popup.

Note that the player should be stopped as soon as the network error is discovered to prevent potential errors.