Refactor captions logic in Plyr video player initialization

Simplify the captions logic in the Plyr video player initialization by using a conditional statement.
Cleaner and more concise code.
This commit is contained in:
Astound 2024-01-22 07:48:00 +08:00
parent 00bd9fee6f
commit 89ae1e265b
Signed by: kaiser
GPG Key ID: 97504AF0027B1A56

View File

@ -1,17 +1,10 @@
(function main() {
'use strict';
let captionsActive;
switch(true) {
case data.settings.subtitles_mode == 2:
captionsActive = true;
break;
case data.settings.subtitles_mode == 1 && data.has_manual_captions:
captionsActive = true;
break;
default:
captionsActive = false;
// Captions
let captionsActive = false;
if (data.settings.subtitles_mode === 2 || (data.settings.subtitles_mode === 1 && data.has_manual_captions)) {
captionsActive = true;
}
// AutoPlay