forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add media partial informations to gallery heading and set cursor to t…
…he start position and consider duration while playing
- Loading branch information
1 parent
77d296e
commit 61874fb
Showing
6 changed files
with
112 additions
and
16 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
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