萤石开放平台(视屏直播)
1.应用的建立
登入萤石开放平台的后台,[开发者服务]-[我的应用],建立一个应用,用于获取 AppKey,AppSecret
2.设置直播
[开发者服务]-[我的资源]中点击[我的设备],如下图操作:
3.各种接口
3.1 获取萤石的AccessToken
/// <summary>
/// 获取萤石的AccessToken
/// </summary>
/// <param name="appKey"></param>
/// <param name="appSecret"></param>
/// <returns></returns>
public static string GetAccessToken(string appKey, string appSecret)
{
string url = "https://open.ys7.com/api/lapp/token/get";
string postData = "appKey=" + appKey + "&appSecret=" + appSecret;
string returnvalue = "";
try
{
returnvalue = Commons.HttpHelper.HttpPost(url, postData);
AccessToken M = new AccessToken();
M = Json.ToObject<AccessToken>(returnvalue);
returnvalue = M.data.accessToken;
}
catch (Exception ex)
{
returnvalue = ex.ToString();
}
return returnvalue;
}
3.2 获取萤石的直播视频列表
/// <summary>
/// 获取萤石的直播视频列表
/// </summary>
/// <param name="accessToken"></param>
/// <returns></returns>
public static VideoList GetVideoList(string accessToken)
{
VideoList M = new VideoList();
try
{
string url = "https://open.ys7.com/api/lapp/live/video/list";
string postData = "accessToken=" + accessToken;
string va = Commons.HttpHelper.HttpPost(url, postData);
M = Json.ToObject<VideoList>(va);
}
catch(Exception ex)
{
M.msg = ex.ToString();
}
return M;
}
其他接口类似书写。
4.手机端效果图