close
Run the Android application
下載圖片
將三個圖片放在res\drawable-hdpi
C:\Users\ryan\workspace\MediaPlayerTest\res\drawable-hdpi\
檔名不支援dash(-)且不支援第一個字大寫
只支援第一個字小寫?!
==========================================================================
載入函式庫
1: package com.example.mediaplayertest;
2:
3: import android.os.Bundle;
4: import android.app.Activity;
5: import android.view.Menu;
6: //------------------------------------------------
7: import android.media.MediaPlayer;
8: import android.media.MediaPlayer.OnCompletionListener;
9: import android.os.AsyncTask;
10: import android.os.Bundle;
11: import android.view.View;
12: import android.view.View.OnClickListener;
13: import android.widget.ImageButton;
14: import android.widget.SeekBar;
15: import android.widget.SeekBar.OnSeekBarChangeListener;
16: import android.widget.TextView;
17: //------------------------------------------------
宣告變數
1:
2: public class MainActivity extends Activity {
3:
4: //--------------------------------------------------
5: // 變數宣告
6: private ImageButton play = null;
7: private ImageButton pause = null;
8: private ImageButton stop = null;
9: private TextView info = null;
10: private MediaPlayer mMediaPlayer = null; // 媒體播放
11: private boolean pauseFlag = false; // 暫停播放標記
12: private boolean playFlag = true; // 播放標記
13: private SeekBar seekbar = null;
14: //--------------------------------------------------
變數初始化
1: //--------------------------------------------------
2: // 變數初始化
3: this.info = (TextView) super.findViewById(R.id.textView1);
4: this.play = (ImageButton) super.findViewById(R.id.imageButton1);
5: this.pause = (ImageButton) super.findViewById(R.id.imageButton2);
6: this.stop = (ImageButton) super.findViewById(R.id.imageButton3);
7: this.seekbar = (SeekBar) super.findViewById(R.id.seekBar1);
8: //--------------------------------------------------
全站熱搜
留言列表