[英]How can I check if Samsung Smart TV has Internet connection?
I need to know if an Internet connection is available before playing a video. 在播放视频之前,我需要知道是否可以使用Internet连接。 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');
}
To check the connectivity of HTTP you can use this following function: http://samsungdforum.com/Guide/ref00011/deviceapi_network_checkhttp.html 要检查HTTP的连接性,可以使用以下功能: http : //samsungdforum.com/Guide/ref00011/deviceapi_network_checkhttp.html
But if for the player, it has some callback functions to handle network error, visit the documentation of player object and see onConnectionFailed, onStreamNotFound, etc http://samsungdforum.com/Guide/ref00014/sef_plugin_player.html 但是,如果对于播放器,它具有一些处理网络错误的回调函数,请访问播放器对象的文档,并查看onConnectionFailed,onStreamNotFound等http://samsungdforum.com/Guide/ref00014/sef_plugin_player.html
I am using this javascript function to check the network on samsung Tv 我正在使用此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;
// }
};
And include this plugin in your HTML page 并将此插件包含在您的HTML页面中
<object id="pluginObjectNetwork" border=0 classid="clsid:SAMSUNG-INFOLINK-NETWORK" style="width: 0px; height: 0px;"></object>
Please Modify this function according to your requirement this function tackles all the Network and internet related issues in samsun 请根据您的要求修改此功能,此功能可解决samsun中所有与网络和Internet相关的问题
You can check the connection status with: 您可以使用以下方法检查连接状态:
if (navigator.onLine) {
player.Play(url);
} else {
alert('Error');
}
However, this method may have compatibility issues with some browsers. 但是,此方法可能与某些浏览器存在兼容性问题。 See: Browser compatibility
另请: 浏览器兼容性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.