Closed GoogleCodeExporter closed 8 years ago
Hi ablozhou,
in Java, you need to "declare" all classes being used either by importing them
or by refering to them with there fully qualified name. So you have two choices
to make it work:
1. import the inner class "OnRangeSeekBarChangeListener":
import <your-package-name>.RangeSeekBar.OnRangeSeekBarChangeListener;
2. Import class "RangeSeekBar" and refer to "OnRangeSeekBarChangeListener" the
following way:
seekBar.setOnRangeSeekBarChangeListener(new
RangeSeekBar.OnRangeSeekBarChangeListener<Double>() { ...
Original comment by tittel@kom.e-technik.tu-darmstadt.de
on 14 May 2012 at 8:04
hey hii i am tejas i am gatting an errror in [seekBar = (seekBar)
findViewById(R.id.SeekBar01);] code and in [mediaPlayer =
MediaPlayer.create(this,R.raw.testsong_20_sec);]code
the error is in raw word and in line of [findViewById(R.id.SeekBar);
i am giving u the whole set of code also below:
package teja.MusicPlayer.main;
import teja.MusicPlayer.main.R;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.SeekBar;
public class MusicPlayerActivity extends Activity {
private Button buttonPlayStop;
private MediaPlayer mediaPlayer;
private SeekBar seekBar;
private final Handler handler = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
private void initView(){
buttonPlayStop = (Button) findViewById(R.id.ButtonPlayStop);
buttonPlayStop.setOnClickListener(new OnClickListener() {
public void onClick(View v){buttonClick();}});
mediaPlayer = MediaPlayer.create(this,R.raw.testsong_20_sec);
seekBar = (seekBar) findViewById(R.id.SeekBar01);
seekBar.setMax(mediaPlayer.getDuration());
seekBar.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent arg1) {
// TODO Auto-generated method stub
seekChange(v);
return false;
}
});
}
public void startPlayProgressUpdater() {
seekBar.setProgress(mediaPlayer.getCurrentPosition());
if (mediaPlayer.isPlaying()) {
Runnable notification = new Runnable() {
public void run() {
startPlayProgressUpdater();
}
};
handler.postDelayed(notification,1000);
}else{
mediaPlayer.pause();
buttonPlayStop.setText(getString(R.string.play_str));
seekBar.setProgress(0);
}
}
private void seekChange(View v){
if(mediaPlayer.isPlaying()){
SeekBar sb = (SeekBar)v;
mediaPlayer.seekTo(sb.getProgress());
}
}
private void buttonClick(){
if (buttonPlayStop.getText() == getString(R.string.play_str)) {
buttonPlayStop.setText(getString(R.string.pause_str));
try{
mediaPlayer.start();
startPlayProgressUpdater();
}catch (IllegalStateException e) {
mediaPlayer.pause();
}
}else{
buttonPlayStop.setText(getString(R.string.play_str));
mediaPlayer.pause();
}
}
}
plzzzz tell me the solution to get reed of this problem.....
Original comment by Tejas...@gmail.com
on 1 Jun 2012 at 4:25
Original issue reported on code.google.com by
abloz...@gmail.com
on 12 May 2012 at 10:44