2011-05-13 100 views
0
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
    // 5 Minutes = 300000 Milliseconds 

    recorder.setMaxDuration(300000); 
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
    recorder.setOutputFile(path); 
    recorder.prepare(); 
    recorder.start(); 

這是我錄製的音頻編碼聲道音頻記錄..在android系統

我需要跟蹤每一秒的時間顯示像00:05記錄的時間。我已經給了5分鐘的時間限制。

+0

你有問題嗎? – 2011-05-13 08:44:55

+0

@Jim Blackler我需要跟蹤每秒記錄的音頻並將其顯示在屏幕上 – jennifer 2011-05-13 08:55:37

+3

嗨Jennifer,這裏有一個很好的教程來做類似的事情http://developer.android.com/resources/articles/timed-ui -updates.html當您開始錄製時,您可以開始計時。 – 2011-05-13 08:57:50

回答

1

謝謝Jim Blackler我明白了:)。

我試圖Updating the UI from a Timer

private Handler mHandler = new Handler(); 

    ... 

    OnClickListener mStartListener = new OnClickListener() { 
    public void onClick(View v) { 
    if (mStartTime == 0L) { 
    mStartTime = System.currentTimeMillis(); 
    mHandler.removeCallbacks(mUpdateTimeTask); 
    mHandler.postDelayed(mUpdateTimeTask, 100); 
    } 
    } 
    }; 


private Runnable mUpdateTimeTask = new Runnable() { 
public void run() { 
final long start = mStartTime; 
long millis = SystemClock.uptimeMillis() - start; 
int seconds = (int) (millis/1000); 
int minutes = seconds/60; 
seconds = seconds % 60; 

if (seconds < 10) { 
mTimeLabel.setText("" + minutes + ":0" + seconds); 
} else { 
mTimeLabel.setText("" + minutes + ":" + seconds); 
} 

mHandler.postAtTime(this, 
start + (((minutes * 60) + seconds + 1) * 1000)); 
} 
};