android 播放3gp的列子
2010-09-17 00:07:00 来源:WEB开发网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);
}
}
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
default:
break;
}
}
};
/**
* 设置按钮是否可用
* @param enabled1 mBt_play
* @param enabled2 mBt_pause
* @param enabled3 mBt_stop
*/
private void setButtonEnabled(boolean enabled1,boolean enabled2,boolean enabled3){
mBt_play.setEnabled(enabled1);
mBt_pause.setEnabled(enabled2);
mBt_stop.setEnabled(enabled3);
}
}
package com.google.activity.media;
import java.io.IOException;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
import com.google.Main;
import com.google.R;
public class IndexActivity extends Main {
更多精彩
赞助商链接