小编Nas*_*ari的帖子

使用ffmpeg与工作经理在后台进行视频处理

当视频处理过程中用户从任务管理器中关闭应用程序然后停止处理时,就会出现问题。

我正在使用FFMpeg在android中进行视频文件处理,它工作正常,但是当我在从任务管理器处理过程中关闭应用程序时,视频处理已停止工作,即使我在工作管理器中添加了所有工作。

    @Override 
public Result doWork() {
        shellCommand = new ShellCommand();
        ffmpegBinary = new String[] {
            FileUtils.getFFmpeg(context).getAbsolutePath()
        };
        command = concatenate(ffmpegBinary, command);
        CommandResult commandResult = getCommandResult(command);
        if (command`enter code here`Result.success) {
            onSuccess(videoPath);
        } else {
            onFailure(videoPath);
        }
    }
    //getCommandResult
    private CommandResult getCommandResult(String[] command) {
        try {
            process = shellCommand.run(command, null);

            if (process == null) {
                return CommandResult.getDummyFailureResponse();
            }
            checkAndUpdateProcess();
            return CommandResult.getOutputFromProcess(process);
        } catch(Exception e) {} finally {
            Util.destroyProcess(process);
        }`enter code here`
        return CommandResult.getDummyFailureResponse();
    }
Run Code Online (Sandbox Code Playgroud)

据我所知,当应用程序从后台关闭时,父进程会销毁它并同时销毁其所有子进程,FFMpeg正在使用android进程执行命令并在视频处理过程中检查视频文件状态。

期待着听到您的意见。谢谢

android ffmpeg background-process mp4parser android-workmanager

5
推荐指数
0
解决办法
69
查看次数

如何在BottomSheetDialog android的顶部中心添加关闭按钮?

想要在 BottomSheetDialog 上添加关闭按钮来关闭它。

我正在使用 BottomSheetDialog 的自定义视图(Linearlayout)。

filterDialog = new BottomSheetDialog(context); filterDialog.setContentView(rootView); filterDialog.getWindow().setWindowAnimations(R.style.CustomDialogAnimation); filterDialog.show();

下图是我的过滤器对话框:

在此输入图像描述

这就是我想要实现的目标:

在此输入图像描述

任何帮助将不胜感激。

android android-alertdialog bottom-sheet

4
推荐指数
1
解决办法
3330
查看次数