mirror of https://gitee.com/karson/fastadmin.git
'直播'
parent
b525fd1b49
commit
46e12d9847
|
|
@ -53,66 +53,66 @@ class Live extends Api
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($this->request->request("username")) {
|
if ($this->request->request("username")) {
|
||||||
// $username = $this->request->request("username");
|
$username = $this->request->request("username");
|
||||||
$username = 'xingchao';
|
// $username = 'xingchao';
|
||||||
$sql = "select b.*
|
$sql = "select b.*
|
||||||
from fa_user as a,fa_live as b
|
from fa_user as a,fa_live as b
|
||||||
where a.id=b.user_id and a.username = '$username'";
|
where a.id=b.user_id and a.username = '$username'";
|
||||||
|
|
||||||
$list = Db::query($sql);
|
$list = Db::query($sql);
|
||||||
if (!empty($list)) {
|
if (!empty($list)) {
|
||||||
|
|
||||||
$code = trim(strrchr($list[0]['push_url'], '/'), '/');
|
$code = trim(strrchr($list[0]['push_url'], '/'), '/');
|
||||||
|
|
||||||
$len1 = strlen($list[0]['push_url']);
|
$len1 = strlen($list[0]['push_url']);
|
||||||
$len2 = strlen($code);
|
$len2 = strlen($code);
|
||||||
|
|
||||||
$base_url = substr($list[0]['push_url'],0,$len1 - $len2);
|
$base_url = substr($list[0]['push_url'], 0, $len1 - $len2);
|
||||||
// echo $base_url;
|
// echo $base_url;
|
||||||
|
|
||||||
$list = array(
|
$list = array(
|
||||||
'base_url' => $base_url,
|
'base_url' => $base_url,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = array("rows" => $list);
|
$result = array("rows" => $list);
|
||||||
|
|
||||||
return (json($result));
|
return (json($result));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//创建直播流
|
//创建直播流
|
||||||
$sql = "select id
|
$sql = "select id
|
||||||
from fa_user
|
from fa_user
|
||||||
where username = '$username'";
|
where username = '$username'";
|
||||||
|
|
||||||
$list = Db::query($sql);
|
$list = Db::query($sql);
|
||||||
$user_id = $list[0]['id'];
|
$user_id = $list[0]['id'];
|
||||||
|
|
||||||
$code = time();
|
$code = time();
|
||||||
$base_url = "rtmp://47.104.165.49:1935/live/";
|
$base_url = "rtmp://47.104.165.49:1935/live/";
|
||||||
$push_url = $base_url . $code;
|
$push_url = $base_url . $code;
|
||||||
$pull_url = $push_url;
|
$pull_url = $push_url;
|
||||||
$sql = "INSERT INTO fa_live(push_url,pull_url,user_id,status) VALUES ('$push_url','$pull_url','$user_id','1')";
|
$sql = "INSERT INTO fa_live(push_url,pull_url,user_id,status) VALUES ('$push_url','$pull_url','$user_id','1')";
|
||||||
|
|
||||||
// echo $sql;
|
// echo $sql;
|
||||||
// exit();
|
// exit();
|
||||||
$rs = Db::execute($sql);
|
$rs = Db::execute($sql);
|
||||||
// if ($rs === false) {
|
// if ($rs === false) {
|
||||||
// echo '添加直播流失败';
|
// echo '添加直播流失败';
|
||||||
// } else {
|
// } else {
|
||||||
// echo '添加直播流成功';
|
// echo '添加直播流成功';
|
||||||
// }
|
// }
|
||||||
|
|
||||||
$list = array(
|
$list = array(
|
||||||
'base_url' => $base_url,
|
'base_url' => $base_url,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = array("rows" => $list);
|
$result = array("rows" => $list);
|
||||||
return json($result);
|
return json($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
$total = $this->model
|
$total = $this->model
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue