MCPcopy
hub / github.com/ilyhalight/voice-over-translation / cleanup

Method cleanup

src/index.ts:1161–1205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1159 }
1160
1161 const cleanup = async () => {
1162 if (this.audioPlayer?.player) {
1163 try {
1164 this.audioPlayer.player.removeVideoEvents();
1165 this.audioPlayer.player.src = "";
1166 await this.audioPlayer.player.clear();
1167 } catch (err) {
1168 debug.log("[stopTranslate] audioPlayer cleanup error", err);
1169 }
1170 debug.log("audioPlayer after stopTranslate", this.audioPlayer);
1171 }
1172 this.activeTranslation = null;
1173 const overlayView = this.uiManager.votOverlayView;
1174 if (overlayView) {
1175 for (const control of [
1176 overlayView.videoVolumeSlider,
1177 overlayView.translationVolumeSlider,
1178 overlayView.downloadTranslationButton,
1179 ]) {
1180 if (control) control.hidden = true;
1181 }
1182 }
1183 this.downloadTranslation = null;
1184 this.longWaitingResCount = 0;
1185 this.hadAsyncWait = false;
1186 this.transformBtn("none", localizationProvider.get("translateVideo"));
1187 debug.log(`Volume on start: ${this.volumeOnStart}`);
1188
1189 // Restore the original video volume. If the user adjusted volume while
1190 // ducking was enabled, prefer the latest baseline volume.
1191 const restoreVolume =
1192 typeof this.smartVolumeDuckingBaseline === "number"
1193 ? this.smartVolumeDuckingBaseline
1194 : this.volumeOnStart;
1195
1196 stopSmartVolumeDuckingImpl(this, { restoreVolume });
1197 this.volumeOnStart = undefined;
1198 this.autoVolumeMutedOnStart = undefined;
1199 if (this.autoRetry !== undefined) {
1200 clearTimeout(this.autoRetry);
1201 this.autoRetry = undefined;
1202 }
1203 // Cancel in-flight translation work.
1204 this.resetActionsAbortController("stopTranslate");
1205 };
1206
1207 const inFlight = cleanup().finally(() => {
1208 if (this.stopTranslatePromise === inFlight) {

Callers

nothing calls this directly

Calls 4

transformBtnMethod · 0.95
clearMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected