From 8ea005b04576a26c84e31d7026d314098b1f3d84 Mon Sep 17 00:00:00 2001 From: Anoncer Date: Sat, 13 Jul 2024 14:27:29 +0200 Subject: [PATCH 1/8] Fixes an error when the player would not turn on --- javascript/pages/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/pages/watch.js b/javascript/pages/watch.js index 7d627a1..26046eb 100644 --- a/javascript/pages/watch.js +++ b/javascript/pages/watch.js @@ -139,7 +139,7 @@ Main(async (e) => { e.functional.control(e.functional.methods[10], { episode: next_episode }); e.episodes.selected_episode = next_episode; e.episodes.AnimateSelect(next_episode); - SaveLData(next_episode, e.translation.id_translation); + SaveLData(next_episode, e.translation.id); History().add(false, 0, 0, next_episode); }); From 3d85a11fb470e89008890444745bb46825a2026a Mon Sep 17 00:00:00 2001 From: Anoncer Date: Sat, 13 Jul 2024 14:28:00 +0200 Subject: [PATCH 2/8] Fixes an error when the player would not turn on --- javascript/pages/watch/mod_player.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/pages/watch/mod_player.js b/javascript/pages/watch/mod_player.js index 863343c..da4b1d5 100644 --- a/javascript/pages/watch/mod_player.js +++ b/javascript/pages/watch/mod_player.js @@ -105,7 +105,7 @@ const player = { * @param {Int} id - перевода */ select: function (id, user_handler = false) { - if (this.id == id) return; + if (this.id == id || id === undefined) return; // Проверяем на существование такго обьекта в DOM const element = $(`.voice[data-id="${id}"]`)[0]; const data = player.data.find((x) => x.translation.id == id); From 4d47800a18b031fad01b1527ab591f132ded2c53 Mon Sep 17 00:00:00 2001 From: Anoncer Date: Sat, 13 Jul 2024 14:30:27 +0200 Subject: [PATCH 3/8] Remover parameters auto next in player --- javascript/menu.js | 20 +--- javascript/pages/player/mod_functions.js | 130 ++--------------------- javascript/pages/player/mod_settings.js | 20 +--- javascript/pages/player/mod_ui.js | 53 +-------- javascript/parametrs.js | 1 - player.html | 8 -- 6 files changed, 13 insertions(+), 219 deletions(-) diff --git a/javascript/menu.js b/javascript/menu.js index e71f0fc..4077e99 100644 --- a/javascript/menu.js +++ b/javascript/menu.js @@ -510,20 +510,6 @@ const IntercatMenu = { }, line: { - }, - standartcontrol: { - type: "parametr", - disabled: () => { - return false; - }, - value: () => { - return $PARAMETERS.player.autonekst; - }, - text: "Автопереключение", - icon: ``, - event: (bool) => { - setParameter('autonekst', bool); - } }, fullscreen: { type: "parametr", @@ -550,10 +536,8 @@ const IntercatMenu = { event: (bool) => { setParameter('standart', bool); }, - text: "Плеер", - icon: ` - - ` + text: "Tunime плеер", + icon: `` } } } \ No newline at end of file diff --git a/javascript/pages/player/mod_functions.js b/javascript/pages/player/mod_functions.js index 62dfc5d..549f619 100644 --- a/javascript/pages/player/mod_functions.js +++ b/javascript/pages/player/mod_functions.js @@ -6,21 +6,17 @@ * Библиотеки: rxjs.js, jqery.js * Возвращает: InitFunctions, CURSOR_WIDTH, onPlaybackRate2$ */ -import { AnimeQuery, Player, hls, onBuffered$, toggleFullScreen } from "../player.js"; +import { Player, hls, toggleFullScreen } from "../player.js"; import { AnimSkip } from "./mod_animation.js"; import { SendAPI } from "./mod_api.js"; -import { onDuration$, onTimeUpdate$ } from "./mod_event.js"; -import { ALTERNATIVE_FULLSCREEN, AUTO_NEKST } from "./mod_settings.js"; +import { onEnded$, onTimeUpdate$ } from "./mod_event.js"; +import { ALTERNATIVE_FULLSCREEN } from "./mod_settings.js"; import { InitShortcuts } from "./mod_shortcuts.js"; import { Skips } from "./mod_stream.js"; -let END_TIME = 0; //Продолжительность видео после обрезки //Настоящий размер курсора export const CURSOR_WIDTH = 33; -//Вызов события при изменения endtime -const onEndTime$ = new rxjs.Subject(); - //Вызов при воспроизведении x2 export const onPlaybackRate2$ = new rxjs.Subject(); @@ -130,36 +126,6 @@ export function InitFunctions() { } }); - - - onDuration$.subscribe({ - next: () => { - if (AUTO_NEKST && Player.duration) { - let end_time_list = localStorage.getItem('tun-end-point'); - if (!end_time_list) end_time_list = {}; else end_time_list = JSON.parse(end_time_list); - if (end_time_list && end_time_list[AnimeQuery.id]) { - END_TIME = Player.duration - end_time_list[AnimeQuery.id].time; - } else { - //Сделать проверку если видео нету обрезки то поставить на 2% - END_TIME = Player.duration - (2 / 100) * Player.duration; - } - onEndTime$.next(END_TIME); - } - } - }); - - onTimeUpdate$.subscribe({ - next: () => { - if (AUTO_NEKST && END_TIME != 0) { - if (Player.currentTime >= END_TIME && !api_nexte_called) { - Player.currentTime = 0; - SendAPI.next(); - api_nexte_called = !api_nexte_called; - } - } - } - }); - onTimeUpdate$.subscribe({ next: () => { if (Skips.list.length <= 0) { @@ -176,21 +142,15 @@ export function InitFunctions() { AnimSkip.hide(); } } - }) + }); - onBuffered$.subscribe({ - next: (time) => { - if (AUTO_NEKST && END_TIME != 0) { - if (time >= END_TIME) { - console.log('[plr] - Buffered stoped'); - hls.stopLoad(); - } - } + onEnded$.subscribe({ + next: () => { + SendAPI.next(); } }); CurrentPointScroll(); - TrimPointScroll(); InitShortcuts(); } @@ -198,17 +158,6 @@ export function ResetFunctions() { api_nexte_called = false; } -onEndTime$.subscribe({ - next: (endtime) => { - const slid = $('.player-slides > .trim-slid'); - const cursor = $('.player-cursors > .trim-cursor'); - let prcnt = ((Player.duration - endtime) / Player.duration) * 100; - slid.width(`${prcnt}%`) - cursor.css({ right: `calc(${prcnt}% - ${CURSOR_WIDTH / 2}px)` }); - hls.startLoad(); - } -}) - /** * Управление currentTime скролл */ @@ -267,71 +216,6 @@ function CurrentPointScroll() { }); } -/** - * Управление trim скролл - */ -function TrimPointScroll() { - const slid = $('.player-slides > .trim-slid'); - const cursor = $('.player-cursors > .trim-cursor'); - - cursor.on('mousedown touchstart', function (e) { - //Проверяем что видео прогрузилось и готово - if (Player.duration == 0) return; - //Координаты нажатия на cursor - let startX = e.clientX || e.originalEvent.touches[0].clientX; - let played = false; - //Останавливаем плеер если вопсроизводиться - if (!Player.paused) { - Player.pause(); - played = true; //Запоминаем что плеер воспроизводился раньше - } - - //Текущая длина slid - let curWidth = slid.width(); - //Смещение курсора - let cursorLeft = cursor.position().left; - let event = true; - - $(window).on('mousemove.ev touchmove.ev', function (e) { - //Координаты смещения - let currentX = e.clientX || e.originalEvent.touches[0].clientX || e.originalEvent.clientX; - let swipeDistance = currentX - startX; - let width = curWidth + -swipeDistance; - if ((window.innerWidth - $('.player-slides > .current-slid').width()) <= width) { - _endevent(); - return; - } - cursor.css('right', (window.innerWidth - cursorLeft) - swipeDistance); - cursor.css({ right: `calc(${(window.innerWidth - cursorLeft) - swipeDistance - (CURSOR_WIDTH / 2)}px - ${CURSOR_WIDTH / 2}px)` }); - slid.width((curWidth + -swipeDistance)); - e.preventDefault(); - }); - - $(window).on('mouseup.ev touchend.ev', function (e) { - _endevent(); - }); - - function _endevent() { - if (event) { - $(window).off('mousemove.ev touchmove.ev'); - $(window).off('mouseup.ev touchend.ev'); - event = false; - let prcnt = (slid.width() / window.innerWidth) * 100; - let timeTrim = (prcnt / 100) * Player.duration; - END_TIME = Player.duration - timeTrim; - slid.css({ width: `${prcnt}%` }); - cursor.css({ right: `calc(${prcnt}% - ${CURSOR_WIDTH / 2}px)` }); - if (played) Player.play(); - let end_time_list = localStorage.getItem('tun-end-point'); - if (!end_time_list) end_time_list = {}; else end_time_list = JSON.parse(end_time_list); - let time = Player.duration - END_TIME - end_time_list[AnimeQuery.id] = { date: new Date(), time: time }; - localStorage.setItem('tun-end-point', JSON.stringify(end_time_list)); - } - } - }); -} - /** * Переключение режима PIP */ diff --git a/javascript/pages/player/mod_settings.js b/javascript/pages/player/mod_settings.js index b8f0ec6..dd42477 100644 --- a/javascript/pages/player/mod_settings.js +++ b/javascript/pages/player/mod_settings.js @@ -4,16 +4,15 @@ * качества, Переключение на следующий эпизод, Упарвлению * громкостью видео. * Библиотеки: rxjs.js, jqery.js - * Возвращает: InitSettings, QUALITY, AUTO_NEKST, FULL_PLAYER, AUTOQUALITY, + * Возвращает: InitSettings, QUALITY, FULL_PLAYER, AUTOQUALITY, * STANDART, STANDART_CONTROLS, onQualityChange$, - * onAutoNekstChange$, ALTERNATIVE_FULLSCREEN + * ALTERNATIVE_FULLSCREEN */ import { Player, hls } from "../player.js"; import { onVolumeChange$ } from "./mod_event.js"; export let QUALITY = $PARAMETERS.player.quality; -export let AUTO_NEKST = $PARAMETERS.player.autonekst; export const FULL_PLAYER = $PARAMETERS.player.full; export const AUTOQUALITY = $PARAMETERS.player.autoquality; export const STANDART = $PARAMETERS.player.standart; @@ -27,13 +26,6 @@ export const onQualityChange$ = new rxjs.Subject().pipe( rxjs.distinctUntilChanged() ); -/** - * Измененеие параметра автопереключение - */ -export const onAutoNekstChange$ = new rxjs.Subject().pipe( - rxjs.distinctUntilChanged() -); - /** * Инициализация окна с настройками */ @@ -45,13 +37,6 @@ export function InitSettings() { onQualityChange$.next(QUALITY); }); - $(`.autonekst-setup`).on('click', function (e) { - if (e.target.type == "checkbox") { - AUTO_NEKST = e.target.checked; - onAutoNekstChange$.next(AUTO_NEKST); - } - }); - //Управление громкостью видео $(`.player-settings > .volume > .slide`).on('mousedown touchstart', function (e) { let startX = e.clientX || e.originalEvent.touches[0].clientX; @@ -95,7 +80,6 @@ export function InitSettings() { SetVolume(); $(`.quality-setup > .quality[data-q="${QUALITY}"]`).addClass('selected'); - $(`.autonekst-setup > .checkbox > input`).prop('checked', AUTO_NEKST); } //Изменение качество видеоролика diff --git a/javascript/pages/player/mod_ui.js b/javascript/pages/player/mod_ui.js index 2ee5db7..77aaeda 100644 --- a/javascript/pages/player/mod_ui.js +++ b/javascript/pages/player/mod_ui.js @@ -11,7 +11,7 @@ import { Player, onBuffered$ } from "../player.js"; import { AnimButtonStatus, AnimRate, AnimSettings } from "./mod_animation.js"; import { onDuration$, onPause$, onPlay$, onTimeUpdate$, onVolumeChange$ } from "./mod_event.js"; import { CURSOR_WIDTH, onPlaybackRate2$ } from "./mod_functions.js"; -import { AUTO_NEKST, STANDART_CONTROLS, onAutoNekstChange$ } from "./mod_settings.js"; +import { STANDART_CONTROLS } from "./mod_settings.js"; import { Skips } from "./mod_stream.js"; /** @@ -68,7 +68,7 @@ export function InitUI() { } }); - $('.player-skip').on('click', function (){ + $('.player-skip').on('click', function () { Skips.Skip(); }); @@ -76,7 +76,6 @@ export function InitUI() { SubscribePlayerControlsEvent(); SubscribeCurrentCursorsEvents(); - SubscribeTrimCursorEvents(); } /** @@ -89,7 +88,6 @@ export function InitUICallbacks() { AnimButtonStatus.pause(); $('.l-controls > .switch-button').addClass('status-pause'); subCurrentCursor$.next(true); - subTrimCursor$.next(true); subControls$.next('p.pause'); } }); @@ -139,17 +137,6 @@ export function InitUICallbacks() { }) } }); - onAutoNekstChange$.subscribe({ - next: () => { - if (AUTO_NEKST) { - $(`.player-slides > .trim-slid`).removeClass('hide'); - $(`.trim-cursor`).removeClass('hide'); - } else { - $(`.player-slides > .trim-slid`).addClass('hide'); - $(`.trim-cursor`).addClass('hide'); - } - } - }); onPlaybackRate2$.subscribe({ next: (israte) => { if (israte) { @@ -219,11 +206,9 @@ function SubscribePlayerControlsEvent() { inControls = true; subControls$.next('c.mouseenter'); subCurrentCursor$.next(true); - subTrimCursor$.next(true); }); controls.on('mousemove', function () { subCurrentCursor$.next(true); - subTrimCursor$.next(true); }); controls.on('mouseleave', function () { inControls = false; @@ -318,40 +303,6 @@ function HideCurerentCursor() { }, 3000); } -const subTrimCursor$ = new rxjs.Subject(); - -function SubscribeTrimCursorEvents() { - $('.player-cursors > .trim-cursor').on('touchstart mouseenter', function () { - inCursor = true; - clearTimeout(timerHideTrimCursor); - clearTimeout(timerHideControls); - - clearTimeout(timerHideCurrentCursors); - $('.player-cursors > .current-cursor').addClass('hide'); - }); - $('.player-cursors > .trim-cursor').on('touchend mouseleave', function () { - inCursor = false; - subTrimCursor$.next(true); - subControls$.next('cl.mouseleave'); - }) -} - -subTrimCursor$.subscribe({ - next: () => { - if (!AUTO_NEKST) return; - HideTrimCursor(); - } -}); - -let timerHideTrimCursor; - -function HideTrimCursor() { - $('.player-cursors > .trim-cursor').removeClass('hide'); - clearTimeout(timerHideTrimCursor); - timerHideTrimCursor = setTimeout(() => { - $('.player-cursors > .trim-cursor').addClass('hide'); - }, 3000); -} export function calculatePercentageWatched(videoDuration, currentTime) { if (currentTime > videoDuration) { diff --git a/javascript/parametrs.js b/javascript/parametrs.js index b3c7368..cc7d50a 100644 --- a/javascript/parametrs.js +++ b/javascript/parametrs.js @@ -29,7 +29,6 @@ const $PARAMETERS = { full: false, alternative_full: false, standart_controls: false, - autonekst: false, autoquality: true, skipmoments: true }, diff --git a/player.html b/player.html index cbe172a..d7e3093 100644 --- a/player.html +++ b/player.html @@ -30,14 +30,6 @@
720p
- -