即使离开应用程序后,音频响起 - 记录音频

发布于 2025-02-13 18:56:39 字数 160 浏览 0 评论 0原文

我正在构建一个应用程序,用户可以在其中开始记录会话的音频,并且录制应该继续直到他单击停止按钮,即使将应用程序放在介于两者之间。 Google搜索为我提供了诸如Flutter_sound之类的插件,但是即使允许录制音频,也不会明确提及。那么,是否有可以帮助我实现同样的软件包?如果没有,还有其他方法可以做吗?

I am building an app where an user can start recording the audio of a session and the recording should continue till he clicks the stop button, even if leaves the app in between. A google search gave me plugins like flutter_sound but it isn't explicitly mentioned if it would allow recording the audio even if one leaves the app. So is there any package which can help me achieve the same? if not is there any other way to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凯凯我们等你回来 2025-02-20 18:56:39

尽管在退出应用程序时,将录音机保留在录音机上并不是一个好习惯,但为了给您一个答案,您可以尝试 Workmanager

void callbackDispatcher() {
  Workmanager.executeTask((task) {
    //Write codes to record here
    return Future.value(true);
  });
}

Workmanager.initialize(
    callbackDispatcher, //the top level function.
    isInDebugMode: true //If enabled it will post a notification whenever the job is running. Handy for debugging jobs
)

并且要取消它可以添加延迟并致电

Workmanager().cancelByTag("tag")

Though its not a good practice to keep the recorder on when the app is exited, just to give you an answer, you can try workmanager

void callbackDispatcher() {
  Workmanager.executeTask((task) {
    //Write codes to record here
    return Future.value(true);
  });
}

Workmanager.initialize(
    callbackDispatcher, //the top level function.
    isInDebugMode: true //If enabled it will post a notification whenever the job is running. Handy for debugging jobs
)

And to cancel it you can add a delay and call

Workmanager().cancelByTag("tag")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文