0

I need to know if an Internet connection is available before playing a video. How can I get it?

var url = 'http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4';
//url not found (no Internet)
player.Play(url);

Now this code working wrong. Player start play but we have not internet. How can I be sure that I have a connection to the internet?

//pseudo code
if (player.checkInternet){
 player.Play(url);
}else{
 alert('Error');
}
4

3 回答 3

2

要检查 HTTP 的连接性,您可以使用以下函数: http ://samsungdforum.com/Guide/ref00011/deviceapi_network_checkhttp.html

但是如果对于播放器,它有一些回调函数来处理网络错误,请访问播放器对象的文档并查看 onConnectionFailed、onStreamNotFound 等 http://samsungdforum.com/Guide/ref00014/sef_plugin_player.html

于 2013-12-20T00:20:32.577 回答
1

我正在使用这个 javascript 函数来检查三星电视上的网络

Main.CheckConnection = function () {
    //  if(gKeyValues.IsOnTV){
    //  Main.Print("Production environment-------");
    /* For Production Environment */
    var physicalConnection = 0,
    httpStatus = 0;
    var currentInterface = networkPlugin.GetActiveType();
    // If no active connection.
    if (currentInterface == -1) {   //wired=1,wireless=0,no connection=-1
        return false;
    }
    // Check physical connection of current interface.
    physicalConnection = networkPlugin.CheckPhysicalConnection(currentInterface);
    //  Main.Print("Network Status: " + physicalConnection);

    // If not connected or error.
    if (physicalConnection != 1) {
        //Main.okDialog_Init("Message");
        Main.Print("Network disconnected");
        //  Main.IsNetworkActive = false;
        return false;
    }
    // Check HTTP transport.
    httpStatus = networkPlugin.CheckHTTP(currentInterface);
    // If HTTP is not avaliable.
    if (httpStatus != 1) {
        alert("Network disconnected");
        Main.IsNetworkActive = false;
        return false;
    }
    Main.IsNetworkActive = true;
    return true;
    //  }
};

并将此插件包含在您的 HTML 页面中

<object id="pluginObjectNetwork" border=0 classid="clsid:SAMSUNG-INFOLINK-NETWORK" style="width: 0px; height: 0px;"></object>

请根据您的要求修改此功能此功能解决samsun中的所有网络和互联网相关问题

于 2015-03-24T11:41:13.427 回答
0

您可以通过以下方式检查连接状态:

if (navigator.onLine) {
    player.Play(url);
} else {
    alert('Error');
}

但是,此方法可能与某些浏览器存在兼容性问题。请参阅:浏览器兼容性

于 2013-12-19T09:45:30.797 回答