Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

How to add music to andoid project

MediaPlayer mediaPlayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.yoursong);

    mediaPlayer.start();

}

@Override
protected void onPause() {
    super.onPause();
    mediaPlayer.stop();
    mediaPlayer.release();

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #add #music #andoid #project
ADD COMMENT
Topic
Name
1+9 =