Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Integrate media player from slub_web_sachsendigital #1320

Draft
wants to merge 99 commits into
base: master
Choose a base branch
from

Conversation

fschoelzel
Copy link
Contributor

This PR integrates the video/audio player from slub_web_sachsendigital into a new MediaPlayer plugin.
The PR is based on #796 and #818 from @dvoracek-slub

For testing this within the DFG Viewer, I have prepared a DDEV system at https://github.com/dvoracek-slub/ddev-dfgviewer-dist/tree/mediaplayer. It relies on https://github.com/dvoracek-slub/dfg-viewer/tree/dev-mediaplayer and includes a demo METS video document.

There also is a work-in-progress section in the documentation that describes some features and technical aspects of the player. composer docs:serve can be used for local preview.

Update (2022-07-06). Most notable changes:

* Kitodo in general
  
  * Read production place and person names in `Mods` format class. I use this to test GND linking of some audio-related metadata.
  * Add option to show full TOC.

* Media player
  
  * It is now possible to set and export markers/segments in the media. The list is shown in audio mode (press F2).
  * When the METS links preprocessed waveform data, this can be shown (and be used to edit markers). See the DDEV system for an example.
  * First version of handling recordings that are split across multiple media files. Currently, this only works via page reloads.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@sebastian-meyer sebastian-meyer added the ⚙ feature A new feature or enhancement. label Sep 9, 2024
@sebastian-meyer
Copy link
Member

sebastian-meyer commented Sep 9, 2024

You placed a lot of JavaScript files in Resources/Private/JavaScript/. Are you sure those shouldn't be put in Resources/Public/JavaScript/ instead, because they need to be accessible by the client?

Also, please put all unchanged third-party libraries in their own sub-directories separate from your own JS files. There are several reasons for that:

  • It's easier to update dependencies if you know which files are part of a third-party library and don't contain any custom changes.
  • We can exclude third-party libraries from all static analysis checks, especially regarding their code styling. (This will most likely greatly reduce the number of Codacy issues currently reported!)

@fschoelzel fschoelzel force-pushed the dev-mediaplayer branch 3 times, most recently from f8e7a39 to b591463 Compare September 9, 2024 16:09
@fschoelzel
Copy link
Contributor Author

fschoelzel commented Sep 9, 2024

You placed a lot of JavaScript files in Resources/Private/JavaScript/. Are you sure those shouldn't be put in Resources/Public/JavaScript/ instead, because they need to be accessible by the client?

This is correct and was done on purpose. All the files in the Resources/Private/JavaScript/ folder are written to a compressed file called DlfMediaPlayer.js during the build process using webpack. This and the associated .map and vendor file are the only files that the client needs when loading the player.
Additional information to code organization: MediaPlayer/Developers.rst

@fschoelzel
Copy link
Contributor Author

Also, please put all unchanged third-party libraries in their own sub-directories separate from your own JS files. There are several reasons for that:

  • It's easier to update dependencies if you know which files are part of a third-party library and don't contain any custom changes.

  • We can exclude third-party libraries from all static analysis checks, especially regarding their code styling. (This will most likely greatly reduce the number of Codacy issues currently reported!)

As far as i know this two third-party files were copied from the original repository and rewritten by @dvoracek-slub to meet the ES6 typescript requirements:
Resources/Private/JavaScript/DlfMediaPlayer/3rd-party/EventTarget.js
Resources/Private/JavaScript/DlfMediaPlayer/3rd-party/VideoFrame.js

The only other file I found is:
Resources/Private/JavaScript/SlubMediaPlayer/components/equalizer/filters.js

Which in my opinion should not easily be updated, like the other two files, without deeply testing the whole function of the Player.

Apart from that, all other third-party dependencies are located in the Build/node_modules folder and get compressed into the DlfMediaVendor.js file

@fschoelzel
Copy link
Contributor Author

I agree that the files created after the build process should be stored in the Resources/Private/JavaScript/DlfMediaPlayer folder instead of just the JavaScript folder.

…ions in webpack.config

Updated the regular expression in the webpack configuration to ensure that both .css and .less file extensions are correctly anchored at the end of the string. This prevents misleading operator precedence and ensures only the intended files are processed.
- Updated .babelrc to include module-resolver plugin for alias imports.
- Modified webpack.config.js to resolve alias paths for cleaner imports.
- Update ESLint configuration for improved import resolution and compatibility

This change improves the readability and maintainability of import statements by allowing the use of path aliases.
fix warning in webpack build: Skipped data-uri embedding of images/xxx.svg because file not found
Copy link
Member

@sebastian-meyer sebastian-meyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general remarks in addition to the detailed comments below (as discussed in our call):

  • Please remove the DevServer or make it a dev-only dependency if that's possible.
  • Please try to merge DlfMediaPlayer, SlubMediaPlayer and lib/ as much as possible, since those are dependencies of each other anyway which won't work as stand-alone implementations.
    ** At the moment it is really difficult to tell apart what those do, where they are used and how they depend on each other.
    ** The best way of handling this would be to have just two directories: One containing the third-party Shaka player (and possibly other unchanged third-party libraries) and one containing all the Kitodo-specific code.
  • Please add license and author information to every non-third-party file.

/Build/Test/.env
composer.lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't ignore the composer.lock! We want to deliver a known working state of dependencies.

Suggested change
composer.lock

@@ -435,6 +435,7 @@ private function getFiles(array &$details, ?SimpleXMLElement $filePointers): voi
// Check if file has valid @USE attribute.
if (!empty($fileUse[$fileId])) {
$details['files'][$fileUse[$fileId]] = $fileId;
$details['all_files'][$fileUse[$fileId]][] = $fileId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is highly confusing. Also, $details['files'] not being an array holding multiple file identifiers may be a bug.

I'd prefer adapting $details['files'] to hold all file identifiers instead of introducing a confusing new variable with just a slightly different use case. What do you think?

@@ -1468,6 +1530,7 @@ private function getFileRepresentation(string $id, SimpleXMLElement $physicalNod
// Check if file has valid @USE attribute.
if (!empty($fileUse[$fileId])) {
$this->physicalStructureInfo[$id]['files'][$fileUse[$fileId]] = $fileId;
$this->physicalStructureInfo[$id]['all_files'][$fileUse[$fileId]][] = $fileId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. I'd prefer adapting files instead of introducing all_files.


$localizationFactory = GeneralUtility::makeInstance(LocalizationFactory::class);

// TODO: Wouldn't there be a TypoScript utility?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/Global/Translate.html
It's not recommended to implement your own translation function, try to instead use one provided by the TYPO3 framework.

<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.tableofcontents.flexform.showFull</label>
<config>
<type>check</type>
<default>0</default>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default here should definitely be 1 in order to keep the current behavior! Please also make sure that this is the default in TableOfContentsController if the option was not set at all (i. e. after upgrading).

// Manual IIR filter
// https://www.earlevel.com/main/2016/12/01/evaluating-filter-frequency-response/
for (let i = 0; i < this.frequencies_.length; i++) {
const f = /** @type {number} */(this.frequencies_[i])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const f = /** @type {number} */(this.frequencies_[i])
const f = /** @type {number} */(this.frequencies_[i]);

Comment on lines +274 to +283
// midGain = 10 * Math.log10(1 + (baseBoost / freq) ** 2) - 10 * Math.log10(1 + (baseBoostRolloff / freq) ** 2)
// midGain / 10 = Math.log10(1 + (baseBoost / freq) ** 2) - Math.log10(1 + (baseBoostRolloff / freq) ** 2)
// midGain / 10 = Math.log10((1 + (baseBoost / freq) ** 2) / (1 + (baseBoostRolloff / freq) ** 2))
// 10 ^ (midGain / 10) = (1 + (baseBoost / freq) ** 2) / (1 + (baseBoostRolloff / freq) ** 2)

// 10 ^ (((10 * Math.log10(1 + baseBoost ** 2) - 10 * Math.log10(1 + baseBoostRolloff ** 2)) / 2) / 10) = (1 + (baseBoost / freq) ** 2) / (1 + (baseBoostRolloff / freq) ** 2)
// 10 ^ ((Math.log10((1 + baseBoost ** 2) / (1 + baseBoostRolloff ** 2))) / 2) = (1 + (baseBoost / freq) ** 2) / (1 + (baseBoostRolloff / freq) ** 2)
// sqrt((1 + baseBoost ** 2) / (1 + baseBoostRolloff ** 2)) = (1 + (baseBoost / freq) ** 2) / (1 + (baseBoostRolloff / freq) ** 2)

// For midFreq, ask Wolfram Alpha to solve
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@@ -0,0 +1,8 @@
@import "../../../../slub_digitalcollections/Resources/Private/Less/Helper/Variables.less";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add dependencies to slub_digitalcollections!

Comment on lines +142 to +143
'fileGrpVideo' => 'VIDEO,DEFAULT',
'fileGrpVideo' => 'VIDEO,DEFAULT,VIDEO_ALT1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate use of the array key fileGrpVideo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙ feature A new feature or enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants