mirror of
https://github.com/Equicord/Equicord.git
synced 2025-04-01 13:11:57 -04:00
Revert "git(revert): "feat(voiceMessages): Added an option to convert to .ogg for ios support. (#197)""
This reverts commit c81b2c087b
.
This commit is contained in:
parent
f54fdd14a2
commit
2b220f97b9
1 changed files with 38 additions and 2 deletions
|
@ -21,6 +21,9 @@ import "./styles.css";
|
||||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
import { Microphone } from "@components/Icons";
|
import { Microphone } from "@components/Icons";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
|
import { loadFFmpeg } from "@equicordplugins/moreStickers/utils";
|
||||||
|
import { FFmpeg } from "@ffmpeg/ffmpeg";
|
||||||
|
import { fetchFile } from "@ffmpeg/util";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
|
import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
|
||||||
|
@ -28,7 +31,7 @@ import { useAwaiter } from "@utils/react";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { chooseFile } from "@utils/web";
|
import { chooseFile } from "@utils/web";
|
||||||
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
||||||
import { Button, Card, Constants, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
|
import { Button, Card, Constants, Flex, FluxDispatcher, Forms, lodash, Menu, MessageActions, PermissionsBits, PermissionStore, React, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Toasts, useEffect, useState } from "@webpack/common";
|
||||||
import { ComponentType } from "react";
|
import { ComponentType } from "react";
|
||||||
|
|
||||||
import { lastState as silentMessageEnabled } from "../silentMessageToggle";
|
import { lastState as silentMessageEnabled } from "../silentMessageToggle";
|
||||||
|
@ -182,6 +185,17 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) {
|
||||||
!blob.type.startsWith("audio/ogg")
|
!blob.type.startsWith("audio/ogg")
|
||||||
|| blob.type.includes("codecs") && !blob.type.includes("opus")
|
|| blob.type.includes("codecs") && !blob.type.includes("opus")
|
||||||
);
|
);
|
||||||
|
const ffmpegLoaded = React.useState(false);
|
||||||
|
const ffmpeg = React.useState<FFmpeg>(new FFmpeg());
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (ffmpegLoaded[0]) return;
|
||||||
|
|
||||||
|
loadFFmpeg(ffmpeg[0], () => {
|
||||||
|
ffmpegLoaded[1](true);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalRoot {...modalProps}>
|
<ModalRoot {...modalProps}>
|
||||||
|
@ -226,12 +240,13 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) {
|
||||||
<Forms.FormText className={Margins.top8}>
|
<Forms.FormText className={Margins.top8}>
|
||||||
To fix it, first convert it to OggOpus, for example using the <Link href="https://convertio.co/mp3-opus/">convertio web converter</Link>
|
To fix it, first convert it to OggOpus, for example using the <Link href="https://convertio.co/mp3-opus/">convertio web converter</Link>
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
|
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<ModalFooter>
|
<ModalFooter justify={Flex.Justify.BETWEEN} direction={Flex.Direction.HORIZONTAL_REVERSE} align={Flex.Align.STRETCH} wrap={Flex.Wrap.NO_WRAP} separator>
|
||||||
<Button
|
<Button
|
||||||
disabled={!blob}
|
disabled={!blob}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -242,7 +257,28 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) {
|
||||||
>
|
>
|
||||||
Send
|
Send
|
||||||
</Button>
|
</Button>
|
||||||
|
{isUnsupportedFormat && <Button
|
||||||
|
disabled={!blob}
|
||||||
|
onClick={async () => {
|
||||||
|
setBlob(undefined); // so the button disables while converting
|
||||||
|
const ffmpegInstance = ffmpeg[0];
|
||||||
|
const blobUrl = URL.createObjectURL(blob!);
|
||||||
|
const filename = "voice-message-converted.ogg";
|
||||||
|
|
||||||
|
ffmpegInstance.writeFile(filename, await fetchFile(blobUrl));
|
||||||
|
ffmpegInstance.exec(["-i", filename, "-c:a", "libopus", "-b:a", "128k", "-vbr", "on", filename]);
|
||||||
|
|
||||||
|
const data = await ffmpegInstance.readFile(filename);
|
||||||
|
const convertedBlob = new Blob([data], { type: "audio/ogg; codecs=opus" });
|
||||||
|
|
||||||
|
setBlob(convertedBlob);
|
||||||
|
setBlobUrl(convertedBlob);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Convert to OggOpus
|
||||||
|
</Button>}
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
|
|
||||||
</ModalRoot>
|
</ModalRoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue