From ba2c365ac9a5ea97f5851829c92106ffce468f3f Mon Sep 17 00:00:00 2001 From: Viperinius Date: Tue, 5 Jul 2022 16:31:48 +0200 Subject: [PATCH] Use object to return multiple info instead of array. --- src/controllers/playback/video/index.js | 15 ++++++++------- src/elements/emby-slider/emby-slider.js | 15 +++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/controllers/playback/video/index.js b/src/controllers/playback/video/index.js index 379369c64b..277f2483f5 100644 --- a/src/controllers/playback/video/index.js +++ b/src/controllers/playback/video/index.js @@ -1577,25 +1577,26 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components nowPlayingPositionSlider.getChapterNamesAndFractions = function () { showOsd(); + const markers = []; + const item = currentItem; if (item && item.Chapters && item.Chapters.length) { - const chapterNames = []; - const chapterFractions = []; const runtimeDuration = item.RunTimeTicks; for (let i = 0, length = item.Chapters.length; i < length; i++) { const currentChapter = item.Chapters[i]; const fraction = currentChapter.StartPositionTicks / runtimeDuration; - chapterFractions.push(fraction); - chapterNames.push(currentChapter.Name); - } - return [chapterNames, chapterFractions]; + markers.push({ + name: currentChapter.Name, + progress: fraction + }); + } } - return [[], []]; + return markers; }; view.querySelector('.btnPreviousTrack').addEventListener('click', function () { diff --git a/src/elements/emby-slider/emby-slider.js b/src/elements/emby-slider/emby-slider.js index 3ade526569..812a846202 100644 --- a/src/elements/emby-slider/emby-slider.js +++ b/src/elements/emby-slider/emby-slider.js @@ -163,20 +163,19 @@ import '../emby-input/emby-input'; } function updateChapterMarks(range, currentValue) { - if (range.chapterFractions && range.chapterFractions.length && range.chapterMarkElements && range.chapterMarkElements.length) { + if (range.chapterInfo && range.chapterInfo.length && range.chapterMarkElements && range.chapterMarkElements.length) { for (let i = 0, length = range.chapterMarkElements.length; i < length; i++) { - if (range.chapterFractions.length > i) { - setChapterMark(range, mapFractionToValue(range, range.chapterFractions[i]), range.chapterMarkElements[i], currentValue); + if (range.chapterInfo.length > i) { + setChapterMark(range, mapFractionToValue(range, range.chapterInfo[i].progress), range.chapterMarkElements[i], currentValue); } } } } function addChapterMarks(range) { - range.chapterNames = []; - range.chapterFractions = []; + range.chapterInfo = []; if (range.getChapterNamesAndFractions) { - [range.chapterNames, range.chapterFractions] = range.getChapterNamesAndFractions(); + range.chapterInfo = range.getChapterNamesAndFractions(); } function htmlToInsert(chapterName) { @@ -188,8 +187,8 @@ import '../emby-input/emby-input'; return ``; } - range.chapterNames.forEach(chapterName => { - range.chapterMarkContainerElement.insertAdjacentHTML('beforeend', htmlToInsert(chapterName || '')); + range.chapterInfo.forEach(chapter => { + range.chapterMarkContainerElement.insertAdjacentHTML('beforeend', htmlToInsert(chapter.name || '')); }); range.chapterMarkElements = range.chapterMarkContainerElement.querySelectorAll('.sliderChapterMark');