From 27b0d8e1fd592ec1d834415235e83c0499787b2c Mon Sep 17 00:00:00 2001 From: vMohammad24 <62218284+vMohammad24@users.noreply.github.com> Date: Wed, 26 Mar 2025 03:16:03 +0300 Subject: [PATCH] feat(voiceMessages): Added an option to convert to .ogg for ios support. --- src/plugins/voiceMessages/index.tsx | 40 +++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx index 35522301..a1523582 100644 --- a/src/plugins/voiceMessages/index.tsx +++ b/src/plugins/voiceMessages/index.tsx @@ -21,6 +21,9 @@ import "./styles.css"; import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { Microphone } from "@components/Icons"; 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 { Margins } from "@utils/margins"; 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 { chooseFile } from "@utils/web"; 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 { lastState as silentMessageEnabled } from "../silentMessageToggle"; @@ -182,6 +185,17 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) { !blob.type.startsWith("audio/ogg") || blob.type.includes("codecs") && !blob.type.includes("opus") ); + const ffmpegLoaded = React.useState(false); + const ffmpeg = React.useState(new FFmpeg()); + + React.useEffect(() => { + if (ffmpegLoaded[0]) return; + + loadFFmpeg(ffmpeg[0], () => { + ffmpegLoaded[1](true); + }); + }, []); + return ( @@ -226,12 +240,13 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) { To fix it, first convert it to OggOpus, for example using the convertio web converter + )} - + + {isUnsupportedFormat && } + ); }