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

android 播放3gp的列子

 2010-09-17 00:07:00 来源:WEB开发网   
核心提示:Java代码package com.google.activity.media;import java.io.IOException;import android.media.MediaPlayer;import android.media.MediaPlayer.OnCompletionListener;import

Java代码

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 {

/** 日志TAG */

private static final String TAG = ">>>>>>>> IndexActivity.java <<<<<<<";

/** 控制按钮 */

private ImageButton mBt_play, mBt_pause ,mBt_stop;

/** 提示消息 */

private TextView mTextView;

/** 媒体控制类 */

private MediaPlayer mMediaPlayer;

/** 是否是暂停flag */

private boolean mIsPaused = false;

@Override

public void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.media);

setUI();

setAction();

}

/** 获取控件 */

private void setUI(){

mBt_pause = (ImageButton) findViewById(R.id.myButton3);

mBt_play = (ImageButton) findViewById(R.id.myButton1);

mBt_stop = (ImageButton) findViewById(R.id.myButton2);

mTextView = (TextView) findViewById(R.id.myTextView1);

setButtonEnabled(true, false, false);

}

/** 添加事件处理 */

private void setAction(){

mMediaPlayer = new MediaPlayer();

//读取raw文件夹下的mp3文件

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

1 2 3 4 5 6  下一页

Tags:android 播放 gp

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