[英]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.