[android]代码库
package com.example.day_12_media_demo;
import java.io.IOException;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
private MediaPlayer player2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
player2 = new MediaPlayer();
try {
player2.setDataSource("mnt/sdcard/bbb.mp3");
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void but(View v) {
try {
player2.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
player2.start();
}
}
by: 发表于:2017-10-18 09:18:49 顶(0) | 踩(0) 回复
??
回复评论