-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5942 from markusweigelt/improvements-media-partials
Improvements media partials
- Loading branch information
Showing
8 changed files
with
151 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Kitodo/src/main/webapp/WEB-INF/resources/js/modules/media_detail_media_partial.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
/* globals metadataEditor */ | ||
|
||
let initMediaPartial = function () { | ||
let mediaElement = document.querySelector('#imagePreviewForm\\:mediaDetailMediaContainer video, #imagePreviewForm\\:mediaDetailMediaContainer audio'); | ||
let mediaPartial = document.querySelector('#metadataEditorWrapper .columnHeading.mediaPartialHeading'); | ||
if (mediaElement && mediaPartial) { | ||
let durationTime = metadataEditor.gallery.mediaPartial.convertFormattedTimeToMilliseconds(mediaPartial.dataset.mediaPartialDuration); | ||
let startTime = metadataEditor.gallery.mediaPartial.convertFormattedTimeToMilliseconds(mediaPartial.dataset.mediaPartialStart); | ||
let stopTime = (startTime + durationTime) / 1000; | ||
|
||
mediaElement.addEventListener("timeupdate", function () { | ||
if (mediaElement.currentTime >= stopTime) { | ||
mediaElement.currentTime = stopTime; | ||
mediaElement.pause(); | ||
} | ||
}); | ||
|
||
let onCanPlay = function () { | ||
mediaElement.currentTime = startTime / 1000; | ||
}; | ||
|
||
mediaElement.addEventListener("play", function () { | ||
mediaElement.removeEventListener("canplay", onCanPlay); | ||
mediaElement.currentTime = startTime / 1000; | ||
}); | ||
|
||
mediaElement.addEventListener("canplay", onCanPlay); | ||
} | ||
}; | ||
|
||
initMediaPartial(); | ||
|
||
document.addEventListener("kitodo-metadataditor-mediaview-update", initMediaPartial); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters