1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-25 04:07:17 +08:00

Merge branch 'develop' into demo

This commit is contained in:
xiaochong0302 2020-09-27 17:59:13 +08:00
commit cf239e70a0
18 changed files with 64 additions and 69 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Chapter as ChapterService;
use App\Http\Admin\Services\ChapterContent as ChapterContentService;
use App\Http\Admin\Services\Course as CourseService;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Models\Course as CourseModel;
/**
@ -104,7 +105,9 @@ class ChapterController extends Controller
break;
case CourseModel::MODEL_LIVE:
$live = $contentService->getChapterLive($chapter->id);
$streamName = ChapterLiveModel::generateStreamName($chapter->id);
$this->view->setVar('live', $live);
$this->view->setVar('stream_name', $streamName);
break;
case CourseModel::MODEL_READ:
$read = $contentService->getChapterRead($chapter->id);

View File

@ -30,7 +30,7 @@
<div class="layui-form-item">
<label class="layui-form-label">Stream Name</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="stream_name" value="chapter_{{ chapter.id }}" readonly="readonly">
<input class="layui-input" type="text" name="stream_name" value="{{ stream_name }}" readonly="readonly">
</div>
</div>
<div class="layui-form-item">

View File

@ -50,11 +50,11 @@ class ChapterController extends Controller
$this->view->pick('chapter/read');
} elseif ($chapter['model'] == CourseModel::MODEL_LIVE) {
if ($chapter['status'] == LiveModel::STATUS_ACTIVE) {
$this->view->pick('chapter/live_active');
$this->view->pick('chapter/live/active');
} elseif ($chapter['status'] == LiveModel::STATUS_INACTIVE) {
$this->view->pick('chapter/live_inactive');
$this->view->pick('chapter/live/inactive');
} elseif ($chapter['status'] == LiveModel::STATUS_FORBID) {
$this->view->pick('chapter/live_forbid');
$this->view->pick('chapter/live/forbid');
}
}

View File

@ -2,14 +2,14 @@
namespace App\Http\Home\Controllers;
use App\Http\Home\Services\Live as LiveService;
use App\Http\Home\Services\ChapterLive as ChapterLiveService;
use App\Traits\Response as ResponseTrait;
use Phalcon\Mvc\View;
/**
* @RoutePrefix("/live")
*/
class LiveController extends Controller
class ChapterLiveController extends Controller
{
use ResponseTrait;
@ -19,12 +19,12 @@ class LiveController extends Controller
*/
public function chatsAction($id)
{
$service = new LiveService();
$service = new ChapterLiveService();
$chats = $service->getRecentChats($id);
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->pick('chapter/live_chats');
$this->view->pick('chapter/live/chats');
$this->view->setVar('chats', $chats);
}
@ -33,7 +33,7 @@ class LiveController extends Controller
*/
public function statsAction($id)
{
$service = new LiveService();
$service = new ChapterLiveService();
$stats = $service->getStats($id);
@ -45,7 +45,7 @@ class LiveController extends Controller
*/
public function statusAction($id)
{
$service = new LiveService();
$service = new ChapterLiveService();
$status = $service->getStatus($id);
@ -57,7 +57,7 @@ class LiveController extends Controller
*/
public function bindUserAction($id)
{
$service = new LiveService();
$service = new ChapterLiveService();
$service->bindUser($id);
@ -69,7 +69,7 @@ class LiveController extends Controller
*/
public function sendMessageAction($id)
{
$service = new LiveService();
$service = new ChapterLiveService();
$response = $service->sendMessage($id);

View File

@ -5,7 +5,7 @@ namespace App\Http\Home\Services;
use App\Services\Logic\ChapterTrait;
use GatewayClient\Gateway;
class Live extends Service
class ChapterLive extends Service
{
use ChapterTrait;
@ -140,12 +140,12 @@ class Live extends Service
protected function getRecentChatKey($id)
{
return "chapter_recent_chat:{$id}";
return "recent_live_chat:{$id}";
}
protected function getGroupName($id)
{
return "chapter_{$id}";
return "live_{$id}";
}
}

View File

@ -1,25 +0,0 @@
{% extends 'templates/main.volt' %}
{% block content %}
{% if chapter.status == 'active' %}
{{ partial('live/live_active') }}
{% elseif chapter.status == 'inactive' %}
{{ partial('live/live_inactive') }}
{% elseif chapter.status =='forbid' %}
{{ partial('live/live_forbid') }}
{% endif %}
{% endblock %}
{% block include_js %}
{% if chapter.status == 'active' %}
{{ js_include('https://imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.3.js', false) }}
{{ js_include('home/js/chapter.live.player.js') }}
{{ js_include('home/js/chapter.live.chat.js') }}
{{ js_include('home/js/chapter.action.js') }}
{{ js_include('home/js/course.share.js') }}
{% endif %}
{% endblock %}

View File

@ -12,4 +12,9 @@
</span>
</div>
<div class="preview">
<div class="icon"><i class="layui-icon layui-icon-face-cry"></i></div>
<div class="tips">直播已禁止,谢谢关注!</div>
</div>
{% endblock %}

View File

@ -2,22 +2,31 @@
{% block content %}
{% set course_url = url({'for':'home.course.show','id':chapter.course.id}) %}
{% set live_status_url = url({'for':'home.live.status','id':chapter.id}) %}
<div class="breadcrumb">
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
</div>
{% if time() < chapter.start_time %}
<div class="countdown">
<div class="preview countdown">
<div class="icon"><i class="layui-icon layui-icon-time"></i></div>
<div class="timer"></div>
<div class="tips">直播倒计时开始啦,敬请关注!</div>
</div>
{% elseif chapter.start_time < time() and chapter.end_time > time() %}
<div class="countdown">
<div class="preview countdown">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
<div class="timer"></div>
<div class="tips">直播时间到了,主播去哪了?</div>
<div class="tips">直播时间到了,老师去哪了?</div>
</div>
{% else %}
<div class="countdown">
<div class="preview">
<div class="icon"><i class="layui-icon layui-icon-tree"></i></div>
<div class="tips">直播已结束,谢谢关注!</div>
</div>

View File

@ -4,7 +4,7 @@
{% elseif value == '2' %}
<span class="layui-badge layui-bg-blue">直播</span>
{% elseif value == '3' %}
<span class="layui-badge layui-bg-black">图文</span>
<span class="layui-badge layui-bg-black">专栏</span>
{% endif %}
{%- endmacro %}

View File

@ -92,4 +92,14 @@ class ChapterLive extends Model
$this->update_time = time();
}
public static function generateStreamName($id)
{
return "chapter_{$id}";
}
public static function parseFromStreamName($streamName)
{
return str_replace('chapter_', '', $streamName);
}
}

View File

@ -137,9 +137,9 @@ class LiveNotify extends Service
$redis->expire($key, 86400);
}
protected function getChapter($streamId)
protected function getChapter($streamName)
{
$id = str_replace('chapter_', '', $streamId);
$id = ChapterLiveModel::parseFromStreamName($streamName);
$chapterRepo = new ChapterRepo();

View File

@ -3,6 +3,7 @@
namespace App\Services\Logic\Chapter;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Models\Course as CourseModel;
use App\Repos\Chapter as ChapterRepo;
use App\Services\ChapterVod as ChapterVodService;
@ -79,9 +80,9 @@ class BasicInfo extends Service
{
$liveService = new LiveService();
$stream = $this->getStreamName($chapter->id);
$streamName = ChapterLiveModel::generateStreamName($chapter->id);
$playUrls = $liveService->getPullUrls($stream);
$playUrls = $liveService->getPullUrls($streamName);
$chapterRepo = new ChapterRepo();

View File

@ -26,11 +26,6 @@ trait ChapterTrait
*/
protected $chapterUser;
public function getStreamName($id)
{
return "chapter_{$id}";
}
public function checkChapterVod($id)
{
$validator = new ChapterValidator();

View File

@ -2,6 +2,7 @@
namespace App\Services\Logic\Teacher\Console;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Services\Live as LiveService;
use App\Services\Logic\ChapterTrait;
use App\Services\Logic\Service;
@ -17,7 +18,7 @@ class LivePushUrl extends Service
$service = new LiveService();
$steamName = $this->getStreamName($chapter->id);
$steamName = ChapterLiveModel::generateStreamName($chapter->id);
return $service->getPushUrl($steamName);
}

View File

@ -115,7 +115,7 @@ $config['metadata']['lifetime'] = 7 * 86400;
/**
* statsKey
*/
$config['metadata']['statsKey'] = '_PH_METADATA_';
$config['metadata']['statsKey'] = '_METADATA_';
/**
* redis库编号
@ -130,7 +130,7 @@ $config['annotation']['lifetime'] = 7 * 86400;
/**
* statsKey
*/
$config['annotation']['statsKey'] = '_PH_ANNOTATION_';
$config['annotation']['statsKey'] = '_ANNOTATION_';
/**
* 密钥

View File

@ -30,10 +30,6 @@
margin-bottom: 0;
}
.padding20 {
padding: 20px;
}
.center {
text-align: center;
}
@ -77,6 +73,10 @@
text-align: center;
}
.layer .pager {
margin-top: 0;
}
.loading {
padding: 30px;
text-align: center;
@ -127,10 +127,6 @@
font-size: 12px;
}
.logo {
}
.top-nav {
margin-left: 100px;
}
@ -897,21 +893,21 @@
color: #666;
}
.countdown {
.preview {
color: #666;
margin-top: 30px;
text-align: center;
}
.countdown .icon {
.preview .icon {
margin-bottom: 10px;
}
.countdown .icon .layui-icon {
.preview .icon .layui-icon {
font-size: 150px;
}
.countdown .tips {
.preview .tips {
font-size: 16px;
margin: 20px 0;
}