检查以查看Android MediaRecorder是否正在录制 [英] Check to see if Android MediaRecorder is Recording

查看:187
本文介绍了检查以查看Android MediaRecorder是否正在录制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Android 2.2编写了一些代码,该代码使用Android MediaPlayer播放音频文件.在没有深入了解代码细节的情况下,我注意到存在一个名为

I've written some code for Android 2.2 that plays an audio file using the Android MediaPlayer. Without getting into the details of the code, I noticed that there exists a function called

isPlaying()

,使您可以检查MediaPlayer当前是否正在播放音频文件.因此,例如,当以下代码段运行时

that allows you to check if an audio file is currently being played by the MediaPlayer. So, for example, when the following snippet of code runs

Toast.makeText(getApplicationContext(), "Sound playing is: " +
        mediaPlayer.isPlaying(), Toast.LENGTH_SHORT).show();

它显示以下消息

Sound playing is: true / false

取决于是否播放声音.

但是,当我编写一些代码来使用Android MediaRecorder记录麦克风的声音时,我发现 not 看起来好像没有一个名为

When I wrote some code to record sound from the microphone using the Android MediaRecorder, however, I noticed that there did not look like there exists a function called

isRecording()

,用于检查是否正在进行录制.

that checks to see whether a recording is in progress.

所以,我想知道程序员是否有责任,然后通过在他们的代码中嵌入一些逻辑来弄清楚记录是否在进行中?或者是否确实存在执行此操作的方法(检查记录是否存在).进行中),使用Android API提供的另一个内置功能.<​​/p>

So, I was wondering if the onus is on the programmer then to figure out if a recording is in progress by embedding some logic into their code - or if perhaps there indeed exists a way to do this (check if a recording is in progress) by using another in-built function offered by the Android API.

推荐答案

看起来好像根本没有这样的功能.我认为尝试在代码中嵌入一些逻辑以干净地执行此操作是有道理的.

Doesn't look like there is such a function after all. I think it makes sense to try to embed some logic in the code to do this cleanly.

这篇关于检查以查看Android MediaRecorder是否正在录制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆