Commit e39b692a authored by Mark Harding's avatar Mark Harding

(feat): return status of overall video

1 merge request!414WIP: New transcoder
Pipeline #101967302 running with stages
......@@ -23,6 +23,7 @@ class video implements Interfaces\Api, Interfaces\ApiIgnorePam
public function get($pages)
{
$videoManager = Di::_()->get('Media\Video\Manager');
$transcodeStates = Di::_()->get('Media\Video\Transcoder\TranscodeStates');
$video = $videoManager->get($pages[0]);
......@@ -30,6 +31,7 @@ class video implements Interfaces\Api, Interfaces\ApiIgnorePam
'entity' => $video->export(),
'sources' => Factory::exportable($videoManager->getSources($video)),
'poster' => $video->getIconUrl(),
'transcode_status' => $transcodeStates->getStatus($video), // Currently not efficient as no caching
]);
}
......
......@@ -84,6 +84,10 @@ class MediaProvider extends Provider
return new Video\Transcoder\Manager();
}, ['useFactory' => false]);
$this->di->bind('Media\Video\Transcoder\TranscodeStates', function ($di) {
return new Video\Transcoder\TranscodeStates();
}, ['useFactory' => false]);
$this->di->bind('Media\Video\Transcode\TranscodeStorage', function ($di) {
return new Video\Transcoder\TranscodeStorage\S3Storage();
}, ['useFactory' => false]);
......
......@@ -76,7 +76,7 @@ class Manager
$sources = [];
foreach ($transcodes as $transcode) {
if ($transcode->getStatus() != 'completed') {
if ($transcode->getStatus() != Transcoder\TranscodeStates::COMPLETED) {
continue;
}
if ($transcode->getProfile() instanceof Transcoder\TranscodeProfiles\Thumbnails) {
......
......@@ -79,7 +79,7 @@ class Transcode
*/
public function setProfile(TranscodeProfiles\TranscodeProfileInterface $profile): self
{
if ($profile->isProOnly() && !$this->video->getOwnerEntity()->isPro()) {
if ($profile->isProOnly() && $this->video && !$this->video->getOwnerEntity()->isPro()) {
throw new TranscodeProfiles\UnavailableTranscodeProfileException();
}
$this->profile = $profile;
......
Please register or to comment