Skip to content

Commit cb2da4f

Browse files
[FEATURE] Add new Audio/Video UI and Toolbox Plugin (kitodo#1758)
Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
1 parent c03f76e commit cb2da4f

File tree

31 files changed

+791
-75
lines changed

31 files changed

+791
-75
lines changed

Build/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Build/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@babel/eslint-parser": "^7.24.7",
2525
"@babel/plugin-transform-runtime": "^7.24.7",
2626
"@babel/preset-env": "^7.24.7",
27+
"@babel/runtime": "^7.28.4",
2728
"@types/audioworklet": "^0.0.60",
2829
"@types/jest": "^27.5.2",
2930
"@types/jquery": "^3.5.30",

Build/webpack.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = (env, argv) => {
3131
output: {
3232
filename: 'JavaScript/DlfMediaPlayer/[name].js',
3333
path: PUBLIC_PATH,
34+
assetModuleFilename: 'Assets/[name].[hash][ext]',
3435
},
3536
plugins: [
3637
new RemoveEmptyScriptsPlugin(),
@@ -81,6 +82,10 @@ module.exports = (env, argv) => {
8182
},
8283
],
8384
},
85+
{
86+
test: /\.(png|svg|jpg|jpeg|gif)$/i,
87+
type: 'asset/resource',
88+
},
8489
],
8590
},
8691
externals: {
@@ -114,6 +119,7 @@ module.exports = (env, argv) => {
114119
alias: {
115120
// __dirname will stands for your root directory level
116121
// path.resolve will concatenate your project folder location with
122+
Assets: path.resolve(PRIVATE_PATH, `Assets/`),
117123
lib: path.resolve(PRIVATE_PATH, `JavaScript/lib/`),
118124
DlfMediaPlayer: path.resolve(PRIVATE_PATH, `JavaScript/DlfMediaPlayer/`),
119125
SlubMediaPlayer: path.resolve(PRIVATE_PATH, `JavaScript/SlubMediaPlayer/`)

Classes/Controller/MediaPlayerController.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Psr\Http\Message\ResponseInterface;
1616
use Kitodo\Dlf\Common\AbstractDocument;
17+
use Kitodo\Dlf\Common\Helper;
1718
use TYPO3\CMS\Core\Page\AssetCollector;
1819
use TYPO3\CMS\Core\Utility\GeneralUtility;
1920
use TYPO3\CMS\Core\Utility\MathUtility;
@@ -70,6 +71,8 @@ public function mainAction(): ResponseInterface
7071
*/
7172
protected function getVideoInfo(AbstractDocument $doc, int $pageNo): ?array
7273
{
74+
// Get image file use groups
75+
$imageUseGroups = $this->useGroupsConfiguration->getImage();
7376
// Get video file use groups
7477
$videoUseGroups = $this->useGroupsConfiguration->getVideo();
7578
$mainVideoUseGroup = $videoUseGroups[0] ?? '';
@@ -91,7 +94,7 @@ protected function getVideoInfo(AbstractDocument $doc, int $pageNo): ?array
9194
$videoChapters = $this->collectVideoChapters($doc);
9295

9396
// Get additional video URLs
94-
$videoUrl = $this->collectAdditionalVideoUrls($doc, $pageNo, $thumbnailUseGroups, $waveformUseGroups);
97+
$videoUrl = $this->collectAdditionalVideoUrls($doc, $pageNo, $thumbnailUseGroups, $waveformUseGroups, $imageUseGroups);
9598

9699
return [
97100
'start' => $videoChapters[$pageNo - 1]['timecode'] ?? '',
@@ -172,19 +175,33 @@ private function collectVideoChapters(AbstractDocument $doc): array
172175
* @param int $pageNo The page number
173176
* @param array $thumbnailUseGroups An array of thumb file use groups
174177
* @param array $waveformUseGroups An array of waveform file use groups
178+
* @param array $imageUseGroups An array of image file use groups
175179
* @return array An array containing additional video URLs like poster and waveform
176180
*/
177-
private function collectAdditionalVideoUrls(AbstractDocument $doc, int $pageNo, array $thumbnailUseGroups, array $waveformUseGroups): array
181+
private function collectAdditionalVideoUrls(AbstractDocument $doc, int $pageNo, array $thumbnailUseGroups, array $waveformUseGroups, array $imageUseGroups): array
178182
{
179183
$videoUrl = [];
184+
185+
$showPoster = $this->settings['constants']['showPoster'] ?? null;
180186
$thumbFiles = $this->findFiles($doc, 0, $thumbnailUseGroups); // 0 = for whole video (not just chapter)
181-
if (!empty($thumbFiles) && $this->settings['constants']['showPoster'] == 1) {
187+
if (!empty($thumbFiles) && (int) $showPoster === 1) {
182188
$videoUrl['poster'] = $thumbFiles[0];
183189
}
190+
184191
$waveformFiles = $this->findFiles($doc, $pageNo, $waveformUseGroups);
185192
if (!empty($waveformFiles)) {
186193
$videoUrl['waveform'] = $waveformFiles[0];
187194
}
195+
196+
$showAudioLabelImage = $this->settings['constants']['showAudioLabelImage'] ?? null;
197+
$audioLabelImageFiles = $this->findFiles($doc, $pageNo, $imageUseGroups);
198+
if (!empty($audioLabelImageFiles)
199+
&& (int) $showAudioLabelImage === 1
200+
&& Helper::filterFilesByMimeType($audioLabelImageFiles[0], ['image'], ['JPG'], 'mimeType')
201+
) {
202+
$videoUrl['audioLabelImage'] = $audioLabelImageFiles[0];
203+
}
204+
188205
return $videoUrl;
189206
}
190207

Classes/Controller/ToolboxController.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ private function renderTools(): void
8080
match ($tool) {
8181
'tx_dlf_multiviewaddsourcetool', 'multiviewaddsourcetool' => $this->renderToolByName('renderMultiViewAddSourceTool'),
8282
'tx_dlf_annotationtool', 'annotationtool' => $this->renderToolByName('renderAnnotationTool'),
83+
'tx_dlf_audiovideotool', 'audiovideotool' => $this->renderToolByName('renderAudioVideoTool'),
8384
'tx_dlf_fulltextdownloadtool', 'fulltextdownloadtool' => $this->renderToolByName('renderFulltextDownloadTool'),
8485
'tx_dlf_fulltexttool', 'fulltexttool' => $this->renderToolByName('renderFulltextTool'),
8586
'tx_dlf_imagedownloadtool', 'imagedownloadtool' => $this->renderToolByName('renderImageDownloadTool'),
@@ -231,6 +232,34 @@ private function renderAnnotationTool(): void
231232
}
232233
}
233234

235+
/**
236+
* Renders the audio video tool (used in template)
237+
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
238+
*
239+
* @access private
240+
*
241+
* @return void
242+
*/
243+
private function renderAudioVideoTool(): void
244+
{
245+
if (
246+
$this->isDocMissingOrEmpty()
247+
|| empty($this->useGroupsConfiguration->getImage())
248+
) {
249+
// Quit without doing anything if required variables are not set.
250+
return;
251+
}
252+
253+
$this->setPage();
254+
$page = $this->requestData['page'] ?? 0;
255+
$audioLabelImage = $this->getImage($page);
256+
257+
if (!empty($audioLabelImage) && Helper::filterFilesByMimeType($audioLabelImage, ['image'], ['JPG'])) {
258+
// assign flag to view if Audio Label Image is available
259+
$this->view->assign('hasAudioLabelImage', true);
260+
}
261+
}
262+
234263
/**
235264
* Renders the fulltext download tool (used in template)
236265
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)

Documentation/Features/MediaPlayer/Configuration.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ For information on equalizer configuration, see :ref:`the equalizer subpage <eq_
133133
// Whether or not showing the Poster Image, if given, until playback is first started
134134
showPoster = 1
135135
136+
// Whether or not showing the Audio Label-Image in Audio mode inside the media-panel
137+
showAudioLabelImage = 1
138+
136139
// Template of filename used when downloading screenshot (without file extension)
137140
// Placeholders may be used
138141
screenshotFilenameTemplate = sachsen-digital-de_{title}_h{hh}m{mm}s{ss}f{ff}

Documentation/Plugins/Index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ Toolbox
10011001
:Values:
10021002
* tx_dlf_multiviewaddsourcetool
10031003
* tx_dlf_annotationtool
1004+
* tx_dlf_audiovideotool
10041005
* tx_dlf_fulltexttool
10051006
* tx_dlf_imagedownloadtool
10061007
* tx_dlf_imagemanipulationtool
@@ -1059,6 +1060,13 @@ The fulltext is fetched and rendered by JavaScript into the `<div id="tx-dlf-ful
10591060

10601061
**Please note**: To allow JavaScript fetching the fulltext, the `CORS headers <https://en.wikipedia.org/wiki/Cross-origin_resource_sharing>`_ must be configured appropriate on the providing webserver.
10611062

1063+
Audio Video tool
1064+
^^^^^^^^^^^^^
1065+
1066+
This tool loads the Buttons for the Audiolabel-Image, Equalizer and Marker Table
1067+
1068+
:typoscript:`plugin.tx_dlf_audiovideotool.`
1069+
10621070
Model download tool
10631071
^^^^^^^^^^^^^
10641072

55.8 KB
Loading

0 commit comments

Comments
 (0)