package com.example.mythread;
import androidx.appcompat.app.AppCompatActivity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
public class Main2Activity extends AppCompatActivity implements View.OnClickListener {
private Button btn_play,btn_pause,btn_stop,btn_prev,
btn_next;
private SeekBar mysb=null;
private TextView tv_time=null,tv_index=null;
private MediaPlayer mp=null;
@Override
public void onClick(View v) {
int id=v.getId();
switch (id){
case R.id.btn_play:
mp.start();
break;
case R.id.btn_pause:
mp.pause();
break;
case R.id.btn_stop:
mp.stop();
break;
case R.id.btn_prev:
break;
case R.id.btn_next:
break;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
tv_time=(TextView)findViewById(R.id.tv_time);
tv_index=(TextView)findViewById(R.id.tv_index);
btn_play=(Button)findViewById(R.id.btn_play);
btn_play.setOnClickListener(this);
btn_pause=(Button)findViewById(R.id.btn_pause);
btn_pause.setOnClickListener(this);
btn_stop=(Button)findViewById(R.id.btn_stop);
btn_stop.setOnClickListener(this);
btn_prev=(Button)findViewById(R.id.btn_prev);
btn_prev.setOnClickListener(this);
btn_next=(Button)findViewById(R.id.btn_next);
btn_next.setOnClickListener(this);
mysb=(SeekBar)findViewById(R.id.mysb);
mp=MediaPlayer.create(this,R.raw.a1);
}
}
有没有人知道错哪了