正如您所看到的,在此播放器中,我想創建一個數組,可以從本地存儲的內部文本文件中獲取視頻路徑列表您可以在下面的代碼中看到我使用.add
來存儲數組中的路徑。請告訴我一個代碼以讀取文本文件並將其放入名爲videoList
的數組中。提前感謝如何讀取本地文本文件並將數據放入數組中以準備播放列表Android
public class AttractLoopMain extends Activity implements OnCompletionListener,
SurfaceHolder.Callback {
private MediaPlayer mediaPlayer;
private ArrayList<String> videoList = new ArrayList<String>();
private SurfaceHolder holder;
private int currentVideo = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.attract_loop);
//videoList.add("/mnt/sdcard/a1.mp4");
//videoList.add("/mnt/sdcard/a2.mp4");
//videoList.add("/sdcard/download/test9-3.m4v");
SurfaceView surface = (SurfaceView) findViewById(R.id.surface);
holder = surface.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
currentVideo = 0;
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
mediaPlayer.stop();
mediaPlayer.release();
finish();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
在combinati使用的FileReader用BufferedReader逐行閱讀 –
您可以請編輯我的代碼上面...請在此先感謝.. :) – user2079840
Stackoverflow不能這樣工作。請閱讀文檔,嘗試自己編寫代碼,如果您有特殊問題,可以再次詢問 –