Skip to content

Commit

Permalink
paella improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Jun 13, 2024
1 parent 2028d72 commit ceed88c
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 98 deletions.
130 changes: 90 additions & 40 deletions classes/Conf/class.xoctConfGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,62 +104,112 @@ protected function player(): void
protected function updatePlayer(): void
{
$this->ctrl->saveParameter($this, 'subtab_active');
$form = $this->paellConfigFormBuilder->buildForm($this->ctrl->getFormAction($this, self::CMD_UPDATE_PLAYER))
->withRequest($this->http->request());
$form = $this->paellConfigFormBuilder
->buildForm($this->ctrl
->getFormAction($this, self::CMD_UPDATE_PLAYER))
->withRequest($this->http->request());
$data = $form->getData();
if (!$data) {
$this->main_tpl->setContent($this->renderer->render($form));
return;
}

if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_OPTION])) {
$paella_player_option = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_OPTION][0];
PluginConfig::set(PluginConfig::F_PAELLA_OPTION, $paella_player_option);
if ($paella_player_option === PluginConfig::PAELLA_OPTION_URL) {
PluginConfig::set(
PluginConfig::F_PAELLA_URL,
$data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_OPTION][1]['url']
);
// General Settings
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_SECTION_GENERAL])) {
$generals = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_SECTION_GENERAL];
if (isset($generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_OPTION])) {
$paella_player_option = $generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_OPTION][0];
PluginConfig::set(PluginConfig::F_PAELLA_OPTION, $paella_player_option);
if ($paella_player_option === PluginConfig::PAELLA_OPTION_URL) {
PluginConfig::set(
PluginConfig::F_PAELLA_URL,
$generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_OPTION][1]['url']
);
}
}

if (isset($generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_LANGS_OPTION])) {
$paella_fallback_langs_option = $generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_LANGS_OPTION];
PluginConfig::set(PluginConfig::F_PAELLA_FALLBACK_LANGS, $paella_fallback_langs_option);
}

if (isset($generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVENT_VIDEO_DOWNLOAD])) {
$paella_prevent_video_download = $generals[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVENT_VIDEO_DOWNLOAD];
PluginConfig::set(PluginConfig::F_PAELLA_PREVENT_VIDEO_DOWNLOAD, $paella_prevent_video_download);
}
}
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_THEME_URL,
$data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_THEME][1]['url']
);


// Theme Settings
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_THEME])) {
$themes = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_THEME];
if (isset($themes[PaellaConfigFormBuilder::F_PAELLA_PLAYER_THEME])) {
$paella_player_theme = $themes[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_THEME_URL,
$themes[PaellaConfigFormBuilder::F_PAELLA_PLAYER_THEME][1]['url']
);
}
}
if (isset($themes[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_THEME])) {
$paella_player_live_theme = $themes[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,
$themes[PaellaConfigFormBuilder::F_PAELLA_PLAYER_LIVE_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']
);


// Preview Settings
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_PREVIEW])) {
$previews = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_PREVIEW];
if (isset($previews[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_FALLBACK])) {
$paella_player_preview_fallback = $previews[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,
$previews[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_FALLBACK][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) {


// General Settings
if (isset($data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_CAPTION])) {
$captions = $data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_CAPTION];
if (isset($captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_CAPTIONS_OPTION])) {
$paella_fallback_captions_option = $captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_FALLBACK_CAPTIONS_OPTION];
PluginConfig::set(PluginConfig::F_PAELLA_FALLBACK_CAPTIONS, $paella_fallback_captions_option);
}

if (isset($captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_DISPLAY_CAPTION_TEXT_TYPE])) {
$paella_display_caption_text_type = $captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_DISPLAY_CAPTION_TEXT_TYPE];
PluginConfig::set(PluginConfig::F_PAELLA_DISPLAY_CAPTION_TEXT_TYPE, $paella_display_caption_text_type);
}

if (isset($captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_DISPLAY_CAPTION_TEXT_GENERATOR])) {
$paella_display_caption_text_generator =
$captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_DISPLAY_CAPTION_TEXT_GENERATOR];
PluginConfig::set(PluginConfig::F_PAELLA_DISPLAY_CAPTION_TEXT_GENERATOR, $paella_display_caption_text_generator);
}

if (isset($captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_DISPLAY_CAPTION_TEXT_GENERATOR_TYPE])) {
$paella_display_caption_text_generator_type =
$captions[PaellaConfigFormBuilder::F_PAELLA_PLAYER_DISPLAY_CAPTION_TEXT_GENERATOR_TYPE];
PluginConfig::set(
PluginConfig::F_PAELLA_PREVIEW_FALLBACK_URL,
$data[PaellaConfigFormBuilder::F_PAELLA_PLAYER_PREVIEW_FALLBACK][1]['url']
PluginConfig::F_PAELLA_DISPLAY_CAPTION_TEXT_GENERATOR_TYPE,
$paella_display_caption_text_generator_type
);
}
}
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
2 changes: 2 additions & 0 deletions classes/Player/class.xoctPlayerGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ protected function buildJSConfig(Event $event): stdClass

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

$js_config->prevent_video_download = (bool) PluginConfig::getConfig(PluginConfig::F_PAELLA_PREVENT_VIDEO_DOWNLOAD) ?? false;

if ($event->isLiveEvent()) {
// script to check live stream availability
$js_config->check_script_hls = $this->plugin->getDirectory() . '/src/Util/check_hls_status.php';
Expand Down
2 changes: 1 addition & 1 deletion js/opencast/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/opencast/src/Paella/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"global": true
},
"restoreLastTime": {
"enabled": true,
"enabled": false,
"remainingSeconds": 5
}
},
Expand Down
10 changes: 5 additions & 5 deletions js/opencast/src/Paella/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "ilias-paella-player",
"private": true,
"dependencies": {
"paella-basic-plugins": "^1.44.0",
"paella-core": "^1.46.1",
"paella-slide-plugins": "^1.41.1",
"paella-user-tracking": "^1.42.0",
"paella-zoom-plugin": "^1.41.1"
"paella-basic-plugins": "^1.44.7",
"paella-core": "^1.48.2",
"paella-slide-plugins": "^1.41.4",
"paella-user-tracking": "^1.42.2",
"paella-zoom-plugin": "^1.41.3"
},
"scripts": {
"build": "webpack --mode production",
Expand Down
2 changes: 1 addition & 1 deletion js/opencast/src/Paella/paella-player.min.js

Large diffs are not rendered by default.

40 changes: 32 additions & 8 deletions js/opencast/src/Paella/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
paella_theme: '',
paella_theme_live: '',
paella_theme_info: '',
prevent_video_download: false,
},

caption_enabled: true,
Expand All @@ -68,8 +69,7 @@ export default {
this.config = config;
this.config.user_default_language = navigator?.language?.substring(0,2);

// If it is decided to display the full language name of a caption, just uncomment the following method call (compileCaptions)
// this.compileCaptions();
this.generateCaptionText();

this.initPaella();
if (this.config.is_live_stream === true) {
Expand All @@ -93,14 +93,27 @@ export default {
} , false);
},

compileCaptions: function() {
generateCaptionText: function() {
if (this.data?.captions) {
for (const captionIndex in this.data.captions) {
let lang = this.data.captions[captionIndex].lang;
let text = new Intl.DisplayNames([this.config.user_default_language], {type: 'language'}).of(lang);
if (text) {
const lang_code = this.data.captions[captionIndex].lang;
let iso_639_1_lang_code = lang_code;
let lang_name = lang_code;
try {
iso_639_1_lang_code = lang_code.split('-', 2)?.[0].trim() ?? lang_code;
const options = {
type: "language",
languageDisplay: "standard"
};
const display_name_obj = new Intl.DisplayNames([this.config.user_default_language], options);
if (display_name_obj) {
lang_name = display_name_obj.of(iso_639_1_lang_code);
}
} catch (e) {}
if (lang_name) {
let text = lang_name;
if (this.data.captions[captionIndex]?.text) {
text = text + ' - ' + this.data.captions[captionIndex].text;
text += ' ' + this.data.captions[captionIndex].text;
}
this.data.captions[captionIndex].text = text;
}
Expand Down Expand Up @@ -167,7 +180,18 @@ export default {
);
this.paella.bindEvent(
Events.PLAYER_LOADED,
() => this.handleLiveAttributes(),
() => {
this.handleLiveAttributes();

// Apply prevent video download
if (this.config?.prevent_video_download) {
this.paella.videoContainer.streamProvider.players.forEach(player => {
player.video?.addEventListener('contextmenu', (e) => {
e.preventDefault();
});
});
}
},
false
);
this.paella.bindEvent(
Expand Down
14 changes: 14 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,17 @@ config_paella_player_live_theme_info#:#Die Themendatei, die für Livestream-Vide
config_paella_player_preview_fallback#:#Paella Player Preview (fallback)
config_paella_player_preview_fallback_info#:#Die (Fallback-)Player-Vorschau-Hintergrundbilddatei, die angezeigt werden soll. Das übliche Bilddateiformat wie PNG oder JPG wird empfohlen.<br> HINWEIS: Standardmäßig wird das Vorschaubild aus den Videoressourcen geladen.
pp_image_link#:#aktuelle Bilddatei
config_paella_player_display_caption_text_type#:#Caption Text (Typ) anzeigen
config_paella_player_display_caption_text_type_info#:#Wenn aktiviert, enthält der Untertiteltext den Typ der Überschrift, sofern diese in den <a href="https://docs.opencast.org/r/15.x/admin/#configuration/subtitles/#tags" target="_blank">Tags</a> vorhanden ist.
config_paella_player_display_caption_text_generator#:#Caption Text (Generator) anzeigen
config_paella_player_display_caption_text_generator_info#:#Wenn aktiviert, enthält der Untertiteltext den Generator der Überschrift, falls dieser in den <a href="https://docs.opencast.org/r/15.x/admin/#configuration/subtitles/#tags" target="_blank">Tags</a> vorhanden ist.
config_paella_player_display_caption_text_generator_type#:#Caption Text (Generator-Typ) anzeigen
config_paella_player_display_caption_text_generator_type_info#:#Wenn aktiviert, enthält der Untertiteltext den Generatortyp der Überschrift, sofern dieser in den <a href="https://docs.opencast.org/r/15.x/admin/#configuration/subtitles/#tags" target="_blank">Tags</a> vorhanden ist.
config_paella_player_caption_text_generator_type_auto#:#automatisch generiert
config_paella_player_caption_text_generator_type_manual#:#manuell generiert
config_paella_player_section_general#:#Player
config_paella_player_section_theme#:#Themes
config_paella_player_section_preview#:#Preview
config_paella_player_section_caption#:#Caption
config_paella_player_prevent_video_download#:#Video-Download verhindern
config_paella_player_prevent_video_download_info#:#Wenn diese Option aktiviert ist, wird das direkte Herunterladen von Videos vom Player verhindert. <br> Dies können Sie erreichen, indem Sie mit der rechten Maustaste auf das Video klicken und "Video speichern unter" oder ähnliches auswählen.
14 changes: 14 additions & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -722,3 +722,17 @@ config_paella_player_live_theme_info#:#The theme file to be loaded into Paella P
config_paella_player_preview_fallback#:#Paella Player Preview (fallback)
config_paella_player_preview_fallback_info#:#The (fallback) player preview background image file to be displayed. The usual image file format like PNG or JPG is encouraged.<br> NOTE: By default the preview image is loaded from the video resources.
pp_image_link#:#current image file
config_paella_player_display_caption_text_type#:#Display Caption Text (Type)
config_paella_player_display_caption_text_type_info#:#When enabled, the caption text contains the type of the caption if exists in the <a href="https://docs.opencast.org/r/15.x/admin/#configuration/subtitles/#tags" target="_blank">tags</a>.
config_paella_player_display_caption_text_generator#:#Display Caption Text (Generator)
config_paella_player_display_caption_text_generator_info#:#When enabled, the caption text contains the generator of the caption if exists in the <a href="https://docs.opencast.org/r/15.x/admin/#configuration/subtitles/#tags" target="_blank">tags</a>.
config_paella_player_display_caption_text_generator_type#:#Display Caption Text (Generator Type)
config_paella_player_display_caption_text_generator_type_info#:#When enabled, the caption text contains the generator type of the caption if exists in the <a href="https://docs.opencast.org/r/15.x/admin/#configuration/subtitles/#tags" target="_blank">tags</a>.
config_paella_player_caption_text_generator_type_auto#:#automatically generated
config_paella_player_caption_text_generator_type_manual#:#manually generated
config_paella_player_section_general#:#Player
config_paella_player_section_theme#:#Themes
config_paella_player_section_preview#:#Preview
config_paella_player_section_caption#:#Caption
config_paella_player_prevent_video_download#:#Prevent video download
config_paella_player_prevent_video_download_info#:#When enabled, the direct video download from the player is prevented. <br> This can be achieved by right clicking on the video and select "save video as" or similar.
4 changes: 4 additions & 0 deletions src/Model/Config/PluginConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class PluginConfig extends ActiveRecord

public const F_PAELLA_FALLBACK_CAPTIONS = 'paella_conf_fallback_captions';
public const F_PAELLA_FALLBACK_LANGS = 'paella_conf_fallback_langs';
public const F_PAELLA_DISPLAY_CAPTION_TEXT_TYPE = 'paella_conf_display_caption_text_type';
public const F_PAELLA_DISPLAY_CAPTION_TEXT_GENERATOR = 'paella_conf_display_caption_text_generator';
public const F_PAELLA_DISPLAY_CAPTION_TEXT_GENERATOR_TYPE = 'paella_conf_display_caption_text_generator_type';
public const F_PAELLA_PREVENT_VIDEO_DOWNLOAD = 'paella_conf_prevent_video_download';

public const PAELLA_OPTION_DEFAULT = 'default';
public const PAELLA_OPTION_URL = 'url';
Expand Down
Loading

0 comments on commit ceed88c

Please sign in to comment.