Giter VIP home page Giter VIP logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 15, 2024
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 [email protected] on 14 May 2012 at 8:04

  • Changed state: Invalid

from range-seek-bar.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 15, 2024
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 [email protected] on 1 Jun 2012 at 4:25

from range-seek-bar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.