KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a simple player and recorder. Everything works great but have one problem. I want to add seek bar to see progress in playing record and use this seek bar to set the place from the player should play. I have onProgress but with no effect. This is the code: package com.example.recorder; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; public class MainActivity extends Activity implements OnSeekBarChangeListener { private static final String LOG_TAG = "AudioRecordTest"; private static String mFileName = null; private SeekBar seekBar; private MediaRecorder mRecorder = null; private Button startRecord, startPlaying, stopPlaying; private MediaPlayer mPlayer = null; private void onRecord(boolean start) { if (start) { startRecording(); } else { stopRecording(); } } private void startPlaying() { if(mPlayer != null && mPlayer.isPlaying()){ mPlayer.pause(); } else if(mPlayer != null){ mPlayer.start(); }else{ mPlayer = new MediaPlayer(); try { mPlayer.setDataSource(mFileName); mPlayer.prepare(); mPlayer.start(); } catch (IOException e) { Log.e(LOG_TAG, "prepare() failed"); } } } private void stopPlaying() { mPlayer.release(); mPlayer = null; startPlaying.setText("Start playing"); } private void pausePlaying(){ if(mPlayer.isPlaying()){ mPlayer.pause();
Tags (comma-separated)
Save Edits
Cancel