Skip to content

Commit

Permalink
Paella 7 (opencast-ilias#204)
Browse files Browse the repository at this point in the history
* paella update with subtitles (first draft)

* texting draft 2

* requested adjusments

* update test live html file

* add preview fallback feature

* minor bug fix for style sheet set variable

* remove ilias http path from theme urls

* bugfixes: player.css & preview fallbacks

* Adapting to new way of handling captions

* fix: class use

* Merge branch 'oc-php-lib' into paella_7-oc-php-lib

* fix: deafult caption and expand de lang

* fix: presentation node init

* langs adjustments

* fix: according to change request - no. 1

* fix: according to change request - no. 2

* f91f7e5: fix: according to change request - no. 3

* fix: according to change request - no. 4

* fix: according to change request - no. 5

* move paella to js dir: according to change request
  • Loading branch information
ferishili authored Nov 10, 2023
1 parent 94f02e4 commit e1a8b5c
Show file tree
Hide file tree
Showing 70 changed files with 6,302 additions and 1,156 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# General
.DS_Store
.AppleDouble
.LSOverride
.LSOverride
9 changes: 9 additions & 0 deletions classes/Conf/class.xoctConfFormGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ protected function initEventsSection(): void
$te->setRequired(true);
$cbs->addSubItem($te);

$te = new ilSelectInputGUI($this->parent_gui->txt(PluginConfig::F_LIVESTREAM_TYPE), PluginConfig::F_LIVESTREAM_TYPE);
$te->setInfo($this->parent_gui->txt(PluginConfig::F_LIVESTREAM_TYPE . '_info'));
$te->setOptions([
'hls' => $this->parent_gui->txt(PluginConfig::F_LIVESTREAM_TYPE . '_hls'),
'mpegts' => $this->parent_gui->txt(PluginConfig::F_LIVESTREAM_TYPE . '_mpegts'),
]);
$te->setRequired(true);
$cbs->addSubItem($te);

$ni = new ilNumberInputGUI(
$this->parent_gui->txt(PluginConfig::F_START_X_MINUTES_BEFORE_LIVE),
PluginConfig::F_START_X_MINUTES_BEFORE_LIVE
Expand Down
34 changes: 28 additions & 6 deletions classes/Conf/class.xoctConfGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,38 @@ protected function updatePlayer()
);
}
}
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_OPTION])) {
$paella_player_option = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_OPTION][0];
PluginConfig::set(PluginConfig::F_PAELLA_OPTION_LIVE, $paella_player_option);
if ($paella_player_option === PluginConfig::PAELLA_OPTION_URL) {
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_THEME])) {
$paella_player_theme = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_THEME][0];
PluginConfig::set(PluginConfig::F_PAELLA_THEME, $paella_player_theme);
if ($paella_player_theme === PluginConfig::PAELLA_OPTION_URL) {
PluginConfig::set(
PluginConfig::F_PAELLA_URL_LIVE,
$data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_OPTION][1]['url']
PluginConfig::F_PAELLA_THEME_URL,
$data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_THEME][1]['url']
);
}
}
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_THEME])) {
$paella_player_live_theme = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_THEME][0];
PluginConfig::set(PluginConfig::F_PAELLA_THEME_LIVE, $paella_player_live_theme);
if ($paella_player_live_theme === PluginConfig::PAELLA_OPTION_URL) {
PluginConfig::set(PluginConfig::F_PAELLA_THEME_URL_LIVE, $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_THEME][1]['url']);
}
}
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_FALLBACK])) {
$paella_player_preview_fallback = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_FALLBACK][0];
PluginConfig::set(PluginConfig::F_PAELLA_PREVIEW_FALLBACK, $paella_player_preview_fallback);
if ($paella_player_preview_fallback === PluginConfig::PAELLA_OPTION_URL) {
PluginConfig::set(PluginConfig::F_PAELLA_PREVIEW_FALLBACK_URL, $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_FALLBACK][1]['url']);
}
}
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_CAPTIONS_OPTION])) {
$paella_fallback_captions_option = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_CAPTIONS_OPTION];
PluginConfig::set(PluginConfig::F_PAELLA_FALLBACK_CAPTIONS, $paella_fallback_captions_option);
}
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_LANGS_OPTION])) {
$paella_fallback_langs_option = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_LANGS_OPTION];
PluginConfig::set(PluginConfig::F_PAELLA_FALLBACK_LANGS, $paella_fallback_langs_option);
}

$this->ctrl->redirect($this, self::CMD_PLAYER);
}
Expand Down
57 changes: 38 additions & 19 deletions classes/Player/class.xoctPlayerGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class xoctPlayerGUI extends xoctGUI
* @var \ilObjUser
*/
private $user;
/**
* @var \ILIAS\HTTP\Services
*/
private $http;

public function __construct(
EventRepository $event_repository,
Expand All @@ -60,10 +64,13 @@ public function __construct(
global $DIC;
parent::__construct();
$this->user = $DIC->user();
$this->http = $DIC->http();
$this->publication_usage_repository = new PublicationUsageRepository();
$this->objectSettings = $objectSettings instanceof ObjectSettings ? $objectSettings : new ObjectSettings();
$this->event_repository = $event_repository;
$this->paellaConfigService = $paellaConfigServiceFactory->get();
$this->identifier = $this->http->request()->getQueryParams()[self::IDENTIFIER] ?? null;
$this->force_no_chat = (bool) $this->http->request()->getQueryParams()['force_no_chat'] ?? false;
}

/**
Expand All @@ -73,7 +80,11 @@ public function __construct(
*/
public function streamVideo(): void
{
$event = $this->event_repository->find(filter_input(INPUT_GET, self::IDENTIFIER));
if (!isset($this->identifier) || empty($this->identifier)) {
echo "Error: invalid identifier";
exit();
}
$event = $this->event_repository->find($this->identifier);
if (!PluginConfig::getConfig(PluginConfig::F_INTERNAL_VIDEO_PLAYER) && !$event->isLiveEvent()) {
// redirect to opencast
header('Location: ' . $event->publications()->getPlayerLink());
Expand All @@ -89,13 +100,14 @@ public function streamVideo(): void
exit;
}

$jquery_path = iljQueryUtil::getLocaljQueryPath();
$ilias_basic_js_path = './Services/JavaScript/js/Basic.js';
$tpl = $this->plugin->getTemplate("paella_player.html", true, true);

$tpl->setVariable("JQUERY_PATH", $jquery_path);
$tpl->setVariable("ILIAS_BASIC_JS_PATH", $ilias_basic_js_path);

$tpl->setVariable("TITLE", $event->getTitle());
$tpl->setVariable(
"PAELLA_PLAYER_FOLDER",
$this->plugin->getDirectory()
. "/node_modules/paellaplayer/build/player"
);
$tpl->setVariable("DATA", json_encode($data));
$tpl->setVariable("JS_CONFIG", json_encode($this->buildJSConfig($event)));

Expand All @@ -117,8 +129,7 @@ public function streamVideo(): void
} else {
$tpl->setVariable(
"STYLE_SHEET_LOCATION",
ILIAS_HTTP_PATH . '/' . $this->plugin->getDirectory(
) . "/templates/default/player.css"
$this->plugin->getDirectory() . "/templates/default/player.css"
);
}

Expand All @@ -130,16 +141,26 @@ public function streamVideo(): void
protected function buildJSConfig(Event $event): stdClass
{
$js_config = new stdClass();
$paella_config = $this->paellaConfigService->getEffectivePaellaPlayerUrl($event->isLiveEvent());
$paella_config = $this->paellaConfigService->getEffectivePaellaPlayerUrl();
$js_config->paella_config_file = $paella_config['url'];
$js_config->paella_config_livestream_type = PluginConfig::getConfig(PluginConfig::F_LIVESTREAM_TYPE) ?? 'hls';
$js_config->paella_config_resources_path = PluginConfig::PAELLA_RESOURCES_PATH;
$js_config->paella_config_fallback_captions = PluginConfig::getConfig(PluginConfig::F_PAELLA_FALLBACK_CAPTIONS) ?? [];
$js_config->paella_config_fallback_langs = PluginConfig::getConfig(PluginConfig::F_PAELLA_FALLBACK_LANGS) ?? [] ;

$js_config->paella_config_info = $paella_config['info'];
$js_config->paella_config_is_warning = $paella_config['warn'];
$js_config->paella_player_folder = $this->plugin->getDirectory(
) . "/node_modules/paellaplayer/build/player";

$paella_themes = $this->paellaConfigService->getPaellaPlayerThemeUrl($event->isLiveEvent());
$js_config->paella_theme = $paella_themes['theme_url'];
$js_config->paella_theme_live = $paella_themes['theme_live_url'];
$js_config->paella_theme_info = $paella_themes['info'];

$js_config->paella_preview_fallback = $this->paellaConfigService->getPaellaPlayerPreviewFallback();

if ($event->isLiveEvent()) {
$js_config->check_script_hls = $this->plugin->getDirectory(
) . '/src/Util/check_hls_status.php'; // script to check live stream availability
// script to check live stream availability
$js_config->check_script_hls = $this->plugin->getDirectory() . '/src/Util/check_hls_status.php';
$js_config->is_live_stream = true;
$js_config->event_start = $event->getScheduling()->getStart()->getTimestamp();
$js_config->event_end = $event->getScheduling()->getEnd()->getTimestamp();
Expand All @@ -149,7 +170,8 @@ protected function buildJSConfig(Event $event): stdClass

protected function isChatVisible(): bool
{
return !filter_input(INPUT_GET, 'force_no_chat')

return !$this->force_no_chat
&& PluginConfig::getConfig(PluginConfig::F_ENABLE_CHAT)
&& $this->objectSettings->isChatActive();
}
Expand All @@ -164,9 +186,7 @@ protected function initChat(Event $event, ilTemplate $tpl)
$ChatroomAR = ChatroomAR::findBy($event->getIdentifier(), $this->objectSettings->getObjId());
if ($event->isLiveEvent()) {
$tpl->setVariable(
"STYLE_SHEET_LOCATION",
ILIAS_HTTP_PATH . '/' . $this->plugin->getDirectory(
) . "/templates/default/player_w_chat.css"
"STYLE_SHEET_LOCATION", $this->plugin->getDirectory() . "/templates/default/player_w_chat.css"
);
$ChatroomAR = ChatroomAR::findOrCreate($event->getIdentifier(), $this->objectSettings->getObjId());
$public_name = $this->user->hasPublicProfile() ?
Expand All @@ -179,8 +199,7 @@ protected function initChat(Event $event, ilTemplate $tpl)
// show chat history for past live events
$tpl->setVariable(
"STYLE_SHEET_LOCATION",
ILIAS_HTTP_PATH . '/' . $this->plugin->getDirectory(
) . "/templates/default/player_w_chat.css"
$this->plugin->getDirectory() . "/templates/default/player_w_chat.css"
);
$ChatHistoryGUI = new ChatHistoryGUI($ChatroomAR->getId());
$tpl->setVariable('CHAT', $ChatHistoryGUI->render(true));
Expand Down
Loading

0 comments on commit e1a8b5c

Please sign in to comment.