Update scripts/videoplayer.js
This commit is contained in:
parent
0a1286a905
commit
d68e0f14c7
@ -103,6 +103,24 @@ async function loadVideoSequenceByLetters() {
|
||||
currentIndex = 0;
|
||||
}
|
||||
|
||||
// Function to highlight the current word or letter
|
||||
function highlightCurrentText(index) {
|
||||
let wordsOrLetters = currentTranslationMode === 'words' ? inputText.value.trim().split(' ') : inputText.value.trim().split('');
|
||||
|
||||
// Reset the text content and remove previous highlights
|
||||
inputText.innerHTML = '';
|
||||
|
||||
// Rebuild the text content with highlighting
|
||||
wordsOrLetters.forEach((item, i) => {
|
||||
const span = document.createElement('span');
|
||||
span.textContent = item + (currentTranslationMode === 'words' ? ' ' : '');
|
||||
if (i === index) {
|
||||
span.classList.add('highlight');
|
||||
}
|
||||
inputText.appendChild(span);
|
||||
});
|
||||
}
|
||||
|
||||
// Function to play video at a specific index
|
||||
function playVideoAtIndex(index) {
|
||||
if (index < 0 || index >= videoSequence.length) return;
|
||||
@ -111,6 +129,9 @@ function playVideoAtIndex(index) {
|
||||
videoPlayer.play();
|
||||
currentIndex = index;
|
||||
|
||||
// Highlight the current word or letter
|
||||
highlightCurrentText(currentIndex);
|
||||
|
||||
// Update the title with the current word or letter
|
||||
const currentLabel = videoSequence[index].split('/').pop().split('.')[0];
|
||||
document.getElementById('currentLetter').innerText = currentLabel.toUpperCase();
|
||||
|
Loading…
Reference in New Issue
Block a user