diff --git a/app/Builders/Builder.php b/app/Builders/Builder.php index 0872c74c..559ca41e 100644 --- a/app/Builders/Builder.php +++ b/app/Builders/Builder.php @@ -2,9 +2,9 @@ namespace App\Builders; -use Phalcon\Mvc\User\Component; +use Phalcon\Di\Injectable; -class Builder extends Component +class Builder extends Injectable { public function objects(array $items) diff --git a/app/Caches/Cache.php b/app/Caches/Cache.php index f0b2cee4..8653f395 100644 --- a/app/Caches/Cache.php +++ b/app/Caches/Cache.php @@ -3,9 +3,9 @@ namespace App\Caches; use Phalcon\Cache\Backend\Redis as RedisCache; -use Phalcon\Mvc\User\Component; +use Phalcon\Di\Injectable; -abstract class Cache extends Component +abstract class Cache extends Injectable { /** diff --git a/app/Caches/Counter.php b/app/Caches/Counter.php index ad52c178..02b57a5e 100644 --- a/app/Caches/Counter.php +++ b/app/Caches/Counter.php @@ -3,9 +3,9 @@ namespace App\Caches; use App\Library\Cache\Backend\Redis as RedisCache; -use Phalcon\Mvc\User\Component; +use Phalcon\Di\Injectable; -abstract class Counter extends Component +abstract class Counter extends Injectable { /** diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index d752c46a..b1a70e44 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -63,7 +63,6 @@ class VodEventTask extends Task * 获取不到时长视为失败 */ if ($duration == 0) { - $attrs['file']['id'] = $fileId; $attrs['file']['status'] = ChapterModel::FS_FAILED; $chapter->update(['attrs' => $attrs]); return; @@ -77,7 +76,6 @@ class VodEventTask extends Task $vodService->createTransVideoTask($fileId); } - $attrs['file']['id'] = $fileId; $attrs['file']['status'] = ChapterModel::FS_TRANSLATING; $attrs['duration'] = (int)$duration; @@ -106,7 +104,6 @@ class VodEventTask extends Task * 获取不到处理结果视为失败 */ if (empty($processResult)) { - $attrs['file']['id'] = $fileId; $attrs['file']['status'] = ChapterModel::FS_FAILED; $chapter->update(['attrs' => $attrs]); return; diff --git a/app/Http/Admin/Controllers/ChapterController.php b/app/Http/Admin/Controllers/ChapterController.php index f1a40e5d..1dbbfc08 100644 --- a/app/Http/Admin/Controllers/ChapterController.php +++ b/app/Http/Admin/Controllers/ChapterController.php @@ -124,9 +124,13 @@ class ChapterController extends Controller switch ($course->model) { case CourseModel::MODEL_VOD: $vod = $contentService->getChapterVod($chapter->id); - $playUrls = $contentService->getPlayUrls($chapter->id); + $cosPlayUrls = $contentService->getCosPlayUrls($chapter->id); + $remotePlayUrls = $contentService->getRemotePlayUrls($chapter->id); + $remoteDuration = $contentService->getRemoteDuration($chapter->id); $this->view->setVar('vod', $vod); - $this->view->setVar('play_urls', $playUrls); + $this->view->setVar('cos_play_urls', $cosPlayUrls); + $this->view->setVar('remote_play_urls', $remotePlayUrls); + $this->view->setVar('remote_duration', $remoteDuration); break; case CourseModel::MODEL_LIVE: $live = $contentService->getChapterLive($chapter->id); diff --git a/app/Http/Admin/Module.php b/app/Http/Admin/Module.php index 8167ea89..7f4bd54c 100644 --- a/app/Http/Admin/Module.php +++ b/app/Http/Admin/Module.php @@ -10,14 +10,14 @@ use Phalcon\Mvc\ModuleDefinitionInterface; class Module implements ModuleDefinitionInterface { - public function registerAutoLoaders(DiInterface $di = null) + public function registerAutoLoaders(DiInterface $dependencyInjector = null) { } - public function registerServices(DiInterface $di) + public function registerServices(DiInterface $dependencyInjector) { - $di->setShared('view', function () { + $dependencyInjector->setShared('view', function () { $view = new MyView(); $view->setViewsDir(__DIR__ . '/Views'); $view->registerEngines([ @@ -26,7 +26,7 @@ class Module implements ModuleDefinitionInterface return $view; }); - $di->setShared('auth', function () { + $dependencyInjector->setShared('auth', function () { return new AdminAuth(); }); } diff --git a/app/Http/Admin/Services/AuthMenu.php b/app/Http/Admin/Services/AuthMenu.php index 89ec4be7..c0d0e004 100644 --- a/app/Http/Admin/Services/AuthMenu.php +++ b/app/Http/Admin/Services/AuthMenu.php @@ -3,9 +3,9 @@ namespace App\Http\Admin\Services; use App\Services\Auth\Admin as AdminAuth; -use Phalcon\Mvc\User\Component; +use Phalcon\Di\Injectable; -class AuthMenu extends Component +class AuthMenu extends Injectable { protected $authInfo; diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index a4bb6235..42202362 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -47,11 +47,37 @@ class ChapterContent extends Service return $chapterRepo->findChapterOffline($chapterId); } - public function getPlayUrls($chapterId) + public function getCosPlayUrls($chapterId) { $service = new ChapterVodService(); - return $service->getPlayUrls($chapterId); + return $service->getCosPlayUrls($chapterId); + } + + public function getRemotePlayUrls($chapterId) + { + $service = new ChapterVodService(); + + return $service->getRemotePlayUrls($chapterId); + } + + public function getRemoteDuration($chapterId) + { + $chapterRepo = new ChapterRepo(); + + $chapter = $chapterRepo->findById($chapterId); + + $duration = $chapter->attrs['duration'] ?? 0; + + $result = ['hours' => 0, 'minutes' => 0, 'seconds' => 0]; + + if ($duration == 0) return $result; + + $result['hours'] = floor($duration / 3600); + $result['minutes'] = floor(($duration - $result['hours'] * 3600) / 60); + $result['seconds'] = $duration % 60; + + return $result; } public function updateChapterContent($chapterId) @@ -84,6 +110,17 @@ class ChapterContent extends Service { $post = $this->request->getPost(); + if (isset($post['file_id'])) { + $this->updateCosChapterVod($chapter); + } elseif (isset($post['file_remote'])) { + $this->updateRemoteChapterVod($chapter); + } + } + + protected function updateCosChapterVod(ChapterModel $chapter) + { + $post = $this->request->getPost(); + $validator = new ChapterVodValidator(); $fileId = $validator->checkFileId($post['file_id']); @@ -119,6 +156,54 @@ class ChapterContent extends Service $this->updateCourseVodAttrs($vod->course_id); } + protected function updateRemoteChapterVod(ChapterModel $chapter) + { + $post = $this->request->getPost(); + + $validator = new ChapterVodValidator(); + + $hours = $post['file_remote']['duration']['hours'] ?? 0; + $minutes = $post['file_remote']['duration']['minutes'] ?? 0; + $seconds = $post['file_remote']['duration']['seconds'] ?? 0; + + $duration = 3600 * $hours + 60 * $minutes + $seconds; + + $validator->checkDuration($duration); + + $odUrl = $post['file_remote']['od']['url'] ?? ''; + $hdUrl = $post['file_remote']['hd']['url'] ?? ''; + $sdUrl = $post['file_remote']['sd']['url'] ?? ''; + + $fileRemote = []; + + $attrs = $chapter->attrs; + + if (!empty($odUrl)) { + $fileRemote['od']['url'] = $validator->checkFileUrl($odUrl); + $attrs['file']['status'] = ChapterModel::FS_UPLOADED; + $attrs['duration'] = $duration; + } + + if (!empty($hdUrl)) { + $fileRemote['hd']['url'] = $validator->checkFileUrl($hdUrl); + } + + if (!empty($sdUrl)) { + $fileRemote['sd']['url'] = $validator->checkFileUrl($sdUrl); + } + + $chapterRepo = new ChapterRepo(); + + $vod = $chapterRepo->findChapterVod($chapter->id); + $vod->file_remote = $fileRemote; + $vod->update(); + + $chapter->attrs = $attrs; + $chapter->update(); + + $this->updateCourseVodAttrs($vod->course_id); + } + protected function updateChapterLive(ChapterModel $chapter) { $post = $this->request->getPost(); diff --git a/app/Http/Admin/Views/answer/list.volt b/app/Http/Admin/Views/answer/list.volt index 80d3c81c..d25b93b5 100644 --- a/app/Http/Admin/Views/answer/list.volt +++ b/app/Http/Admin/Views/answer/list.volt @@ -40,7 +40,7 @@
格式 | -时长 | -分辨率 | -码率 | -大小 | -操作 | -
---|---|---|---|---|---|
{{ item.format }} | -{{ item.duration|duration }} | -{{ item.width }} x {{ item.height }} | -{{ item.rate }}kbps | -{{ item.size }}M | -- 预览 - 复制 - | -