簡體   English   中英

如何檢查Samsung Smart TV是否可以連接互聯網?

[英]How can I check if Samsung Smart TV has Internet connection?

在播放視頻之前,我需要知道是否可以使用Internet連接。 我怎么才能得到它?

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

現在這段代碼工作不正確。 播放器開始播放,但我們沒有互聯網。 如何確定可以連接到互聯網?

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

要檢查HTTP的連接性,可以使用以下功能: http : //samsungdforum.com/Guide/ref00011/deviceapi_network_checkhttp.html

但是,如果對於播放器,它具有一些處理網絡錯誤的回調函數,請訪問播放器對象的文檔,並查看onConnectionFailed,onStreamNotFound等http://samsungdforum.com/Guide/ref00014/sef_plugin_player.html

我正在使用此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中所有與網絡和Internet相關的問題

您可以使用以下方法檢查連接狀態:

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

但是,此方法可能與某些瀏覽器存在兼容性問題。 另請: 瀏覽器兼容性

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM