WEB开发网
开发学院手机开发Android 开发 android 播放3gp的列子 阅读

android 播放3gp的列子

 2010-09-17 00:07:00 来源:WEB开发网   
核心提示:{mMediaPlayer.stop();}else {mMediaPlayer = new MediaPlayer();mMediaPlayer = MediaPlayer.create(IndexActivity.this,R.raw.u01_2);}/ 在mediaPlayer取得播放资源和stop()之后* 要

{

mMediaPlayer.stop();

}else {

mMediaPlayer = new MediaPlayer();

mMediaPlayer = MediaPlayer.create(IndexActivity.this,R.raw.u01_2);

}

/***

* 在mediaPlayer取得播放资源和stop()之后

* 要准备playback(回放,重放)的状态前一定要mediaPlayer.prepare();

*/

mMediaPlayer.prepare();

mMediaPlayer.start();

mTextView.setText(R.string.str_start);//显示播放信息

} catch (IllegalStateException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// mIsPaused = false;

//设置可以使用的按钮

setButtonEnabled(false, true, true);

break;

//停止按钮

case R.id.myButton2:

try {

if(mMediaPlayer!= null)

{

mMediaPlayer.stop();

mTextView.setText(R.string.str_close);

}

} catch (IllegalStateException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

setButtonEnabled(true, false, false);

break;

//暂停按钮

case R.id.myButton3:

try {

if(mMediaPlayer != null)

{

if(mIsPaused == false)//要暂停当前的音乐

{

Log.i(TAG, "mIsPaused false");

mMediaPlayer.pause();

mIsPaused = true;//设置播放flag为true

mTextView.setText(R.string.str_pause);

setButtonEnabled(true, false, true);

}

else if( mIsPaused == true)//回放

{

Log.i(TAG, "mIsPaused true");

mMediaPlayer.seekTo(80000);

mIsPaused = false;

mTextView.setText(R.string.str_start);

setButtonEnabled(false, true, true);

上一页  2 3 4 5 6 7 8  下一页

Tags:android 播放 gp

编辑录入:coldstar [复制链接] [打 印]
赞助商链接