0

如您所见,在此播放器中,我想创建一个数组,该数组可以从设备内部存储器中本地存储的文本文件中获取视频路径列表。您可以在下面的代码中看到我.add用来存储数组中的路径。请告诉我一个代码来读取文本文件并将其放入名为的数组videoList中。提前致谢

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

}
4

1 回答 1

0

使用此代码

Scanner s = new Scanner(new File("filepath"));
ArrayList<String> list = new ArrayList<String>();
while (s.hasNext()){
    list.add(s.next());
}
s.close();
于 2013-06-05T07:54:58.973 回答