Authored by xiaofeng.yao@yoho.cn

Merge branch 'develop' into test

... ... @@ -306,7 +306,8 @@
"pic": "http:///global?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
"url": "qwe",
"live_title": "qwe",
"audience_num": 0
"audience_num": 0,
"create_time": 1472034199
},
{
"video_id": 3,
... ... @@ -317,7 +318,8 @@
"pic": "http:///global?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
"url": "qwe",
"live_title": "qwe",
"audience_num": 0
"audience_num": 0,
"create_time": 1472034199
}
],
"timestamp": 1471339317,
... ... @@ -336,6 +338,7 @@
| url | str|回看腾讯视频连接
| live_title | str|直播时的房间标题
| audience_num | int|正在观看人数
| create_time | int|视频上传时间
# **直播房间详情**
... ...
... ... @@ -270,6 +270,9 @@ class Room extends \yii\db\ActiveRecord
$model->living = 2;
if ($model->videoRecording){
//停止正在录制的视频
$roomNums = \common\models\RoomNums::getRoomNums($model->room_id);
$model->videoRecording->audience_num = $roomNums['audience_nums'];
$model->videoRecording->like_num = $roomNums['like_nums'];
$model->videoRecording->live_end_time = time();
$model->videoRecording->save();
}
... ...
... ... @@ -95,12 +95,12 @@ $this->registerJs($this->blocks['javascript'],View::POS_END)
</div>
</div>
<!--<div class="form-group">
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label">直播状态: </label>
<div class="col-sm-2">
<?php echo Html::dropDownList('living', $model->living,Yii::$app->params['config']['room_living'], ['class' => 'form-control']);?>
</div>
</div>-->
</div>
<div class="form-group" id="uploader">
<label class="col-sm-3 control-label">头图: <span class="asterisk">*</span></label>
... ...
... ... @@ -4,7 +4,7 @@ return [
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
'keyPrefix' => 'yoho-live',
'keyPrefix' => 'YOHOLive',
],
'redis' => [
'class' => 'yii\redis\Connection',
... ... @@ -13,10 +13,17 @@ return [
'port' => 6379,
'database' => 0,
],
'redisIm' => [
'class' => 'yii\redis\Connection',
'hostname' => '123.56.138.21',
'password' => 'yohoglobal',
'port' => 6379,
'database' => 0,
],
'pageCache' => [
'class' => 'soa\components\pagecache\Redis',
'redis' => 'redis',
'keyPrefix' => 'yoho-live',
'keyPrefix' => 'YOHOLive',
],
'db' => [
'class' => 'yii\db\Connection',
... ...
... ... @@ -34,7 +34,6 @@ return [
'un_forbid_stat'=>0,
//被禁言状态
'is_forbid_stat'=>1,
],
/**
* 分页每页数目
... ... @@ -44,10 +43,16 @@ return [
* 缓存超时时间
*/
'defaultCacheExpire'=>7200,
/**
* 默认缓存前缀
*/
'cache_prefix'=>'YOHOLive',
//成功状态
'success_code'=>200,
//失败状态
'failed_code'=>8001,
//异常状态
'exception_code'=>500
'exception_code'=>500,
//redis prefix
'cache_prefix'=>'Live'
];
... ...
... ... @@ -114,7 +114,7 @@ class Room extends \yii\db\ActiveRecord
*/
public function getVideoRecording()
{
return $this->hasOne(Video::className(), ['room_id'=>'room_id'])->where(['and',['>','live_start_time',0],['live_end_time'=>0]])->orderBy(['create_time'=>SORT_DESC]);
return $this->hasOne(Video::className(), ['room_id'=>'room_id'])->where(['and',['>','live_start_time',0],['live_end_time'=>0]])->orderBy(['live_start_time'=>SORT_DESC]);
}
/**
... ...
... ... @@ -49,4 +49,23 @@ class RoomNums extends \yii\db\ActiveRecord
'vest_online_num' => 'Vest Online Num',
];
}
/**
* 获取房间里的数目
* @param $room_id
* @return array
*/
public static function getRoomNums($room_id)
{
$cache_prefix = Yii::$app->params['cache_prefix'];
//清在线观看数
$audience_nums = Yii::$app->redisIm->get(sprintf($cache_prefix . ":audience_nums_room_%s", $room_id));
//清点赞数
$like_nums = Yii::$app->redisIm->get(sprintf($cache_prefix . ":like_numbers_room_%s", $room_id));
return [
'audience_nums'=>$audience_nums ? :0,
'like_nums'=>$like_nums ?:0
];
}
}
\ No newline at end of file
... ...
... ... @@ -149,13 +149,13 @@ class Video extends \yii\db\ActiveRecord
/*------------清除弹幕相关redis--------------*/
//##主播app 向弹幕服务器发送开始命令时也清除,这里也清除是为了防止弹幕服务器连不上没有清掉
//清掉在线马甲数
Yii::$app->redis->del(sprintf($cache_prefix . ":vestnum_%s", $room_id));
Yii::$app->redisIm->del(sprintf($cache_prefix . ":vestnum_%s", $room_id));
//清在线观看数
Yii::$app->redis->del(sprintf($cache_prefix . ":audience_nums_room_%s", $room_id));
Yii::$app->redisIm->del(sprintf($cache_prefix . ":audience_nums_room_%s", $room_id));
//清点赞数
Yii::$app->redis->del(sprintf($cache_prefix . ":like_numbers_room_%s", $room_id));
Yii::$app->redisIm->del(sprintf($cache_prefix . ":like_numbers_room_%s", $room_id));
//清直播状态
Yii::$app->redis->del(sprintf($cache_prefix . ":play_stat_room_%s", $room_id));
Yii::$app->redisIm->del(sprintf($cache_prefix . ":play_stat_room_%s", $room_id));
/*------------清除弹幕相关redis--------------*/
if (!$result) {
throw new \Exception('tbl_room update error');
... ...
... ... @@ -159,6 +159,7 @@ class LivingController extends BaseController
'live_title'=>$model->live_title,
'live_room_id'=>(int)$model->room_id,
'audience_num'=>(int)($model->audience_num+$model->replay_num),
'create_time'=>(int)$model->create_time,
];
$ret[$k] = $row;
}
... ...