Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class asli extends AppCompatActivity {
- Button clk1, clk2;
- MediaPlayer mp;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.setTitle(" Mad Asli / Mad Thobi'i");
- setContentView(R.layout.activity_asli);
- clk1 = (Button) findViewById(R.id.playid);
- clk2 = (Button) findViewById(R.id.pauseid);
- mp = MediaPlayer.create(this, R.raw.mad_thobii);
- }
- public void clkplay(View v){
- mp.start();
- }
- public void clkpause(View v){
- mp.pause();
- }
- /*dibawah ini untuk berhenti ketika on backpressed */
- @Override
- protected void onStop() {
- super.onStop();
- if(mp!=null && mp.isPlaying())
- {
- mp.stop();
- mp.release();
- mp = null;
- }
- }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if(mp!=null && mp.isPlaying())
- {
- mp.stop();
- mp.release();
- mp = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement