Skip to content

Commit

Permalink
Merge pull request #879 from ilyhalight/fix-audio-player
Browse files Browse the repository at this point in the history
Fix translation button on change video with old player
  • Loading branch information
ilyhalight authored Oct 29, 2024
2 parents dd7a6d0 + 73f0ca3 commit abb7d5f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@

- (ПРОВЕРИТЬ ЕЩЕ РАЗ) Исправлена ошибка из-за которой озвучка иногда могла не стартовать со старым плеером (#840)

# 1.7.1 Beta 4

- Исправлена ошибка из-за которой при смене видео кнопка могла перестать работать со старым плеером ([875#discussioncomment-11085577](https://github.com/ilyhalight/voice-over-translation/discussions/875#discussioncomment-11085577))

# 1.7.1 Beta 3

- Обновлена логика запросов к VOT Worker для поддержки новых запросов из 1.7.1 Beta 2
- Обновлена логика запросов к VOT Worker для поддержки новых запросов из 1.7.1-beta2
- Обновлена логика нового плеера. Теперь, он не использует Tone.js и работает лучше, чем раньше

# 1.7.1 Beta 2
Expand Down
8 changes: 4 additions & 4 deletions dist/vot-min.user.js

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
// @connect onrender.com
// @connect workers.dev
// @namespace vot
// @version 1.7.1-beta3
// @version 1.7.1-beta4
// @icon https://translate.yandex.ru/icons/favicon.ico
// @author sodapng, mynovelhost, Toil, SashaXser, MrSoczekXD
// @homepageURL https://github.com/ilyhalight/voice-over-translation
Expand Down Expand Up @@ -7498,7 +7498,7 @@ class VideoObserver {

;// ./node_modules/chaimu/dist/config.js
/* harmony default export */ const dist_config = ({
version: "1.0.1",
version: "1.0.2",
debug: false,
fetchFn: fetch.bind(window),
});
Expand Down Expand Up @@ -8486,10 +8486,15 @@ class AudioPlayer extends BasePlayer {
});
}
set src(url) {
this._src = url;
if (!url) {
void this.clear();
return;
}
this.audio.src = url;
}
get src() {
return this.audio.src;
return this._src;
}
get currentSrc() {
return this.audio.currentSrc;
Expand Down Expand Up @@ -8592,7 +8597,8 @@ class ChaimuPlayer extends BasePlayer {
try {
await this.chaimu.audioContext.close();
}
catch { }
catch {
}
return this;
}
async clear() {
Expand Down Expand Up @@ -8816,10 +8822,13 @@ class VideoHandler {
* @type {import("./index").VideoHandler['audioContext']}
*/
audioContext = initAudioContext();
// audioPlayer = new AudioPlayer(this);

hls = initHls(); // debug enabled only in dev mode
votClient;

/**
* @type {import("chaimu").default}
*/
audioPlayer;

videoTranslations = [];
Expand Down Expand Up @@ -9761,13 +9770,16 @@ class VideoHandler {
this.audioPlayer.player,
);
if (this.audioPlayer.player.src) {
debug.log("[click translationBtn] audio.src is not empty");
debug.log(
"[click translationBtn] audio.src is not empty",
this.audioPlayer.player.src,
);
this.stopTranslate();
return;
}

if (this.hls.url) {
debug.log("[click translationBtn] hls is not empty");
debug.log("[click translationBtn] hls is not empty", this.hls.url);
this.stopTranslate();
return;
}
Expand Down Expand Up @@ -10919,6 +10931,7 @@ class VideoHandler {
this.audioPlayer.player.removeVideoEvents();
this.audioPlayer.player.clear();
this.audioPlayer.player.src = undefined;
debug.log("audioPlayer after stopTranslate", this.audioPlayer);

this.votVideoVolumeSlider.container.hidden = true;
this.votVideoTranslationVolumeSlider.container.hidden = true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"bowser": "^2.11.0",
"chaimu": "^1.0.1",
"chaimu": "^1.0.2",
"lit": "^3.2.1",
"requestidlecallback-polyfill": "^1.0.2",
"vot.js": "^1.3.6"
Expand Down
2 changes: 1 addition & 1 deletion src/headers.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "[VOT] - Voice Over Translation",
"description": "A small extension that adds a Yandex Browser video translation to other browsers",
"version": "1.7.1-beta3",
"version": "1.7.1-beta4",
"author": "sodapng, mynovelhost, Toil, SashaXser, MrSoczekXD",
"namespace": "vot",
"icon": "https://translate.yandex.ru/icons/favicon.ico",
Expand Down
13 changes: 10 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ class VideoHandler {
* @type {import("./index").VideoHandler['audioContext']}
*/
audioContext = initAudioContext();
// audioPlayer = new AudioPlayer(this);

hls = initHls(); // debug enabled only in dev mode
votClient;

/**
* @type {import("chaimu").default}
*/
audioPlayer;

videoTranslations = [];
Expand Down Expand Up @@ -1045,13 +1048,16 @@ class VideoHandler {
this.audioPlayer.player,
);
if (this.audioPlayer.player.src) {
debug.log("[click translationBtn] audio.src is not empty");
debug.log(
"[click translationBtn] audio.src is not empty",
this.audioPlayer.player.src,
);
this.stopTranslate();
return;
}

if (this.hls.url) {
debug.log("[click translationBtn] hls is not empty");
debug.log("[click translationBtn] hls is not empty", this.hls.url);
this.stopTranslate();
return;
}
Expand Down Expand Up @@ -2201,6 +2207,7 @@ class VideoHandler {
this.audioPlayer.player.removeVideoEvents();
this.audioPlayer.player.clear();
this.audioPlayer.player.src = undefined;
debug.log("audioPlayer after stopTranslate", this.audioPlayer);

this.votVideoVolumeSlider.container.hidden = true;
this.votVideoTranslationVolumeSlider.container.hidden = true;
Expand Down

0 comments on commit abb7d5f

Please sign in to comment.