here's my code but there's no sound being played
MainActivity.java
public class MainActivity extends AppCompatActivity {
private MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mediaPlayer = MediaPlayer.create(MainActivity.this,R.raw.file);
Button playButton = (Button) findViewById(R.id.play_id);
playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mediaPlayer.start();
}
});
Button pauseButton = (Button) findViewById(R.id.pause_id);
playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mediaPlayer.stop();
}
});
}
my code works but there's no sound being played. i don't know what's wrong
also the format of the mp3 is weird it shows YT with black background which i don't understand.
Thanks for the try but it was my mistake in this line playButton.setOnClickListener(new View.OnClickListener() { it should be pauseButton, i only forgot to change it. Thanks