1
我正在做一個項目,其中有多個產品類別,每個產品類別包含一個視頻。 我通過從網絡服務獲取網址來播放視頻。當我第一次播放該視頻時,應該只從該網址下載該視頻一次。當沒有互聯網連接時,它應該從下載地點播放(SD卡)。假設我已經爲所有三種產品下載了3個視頻,現在我必須在沒有互聯網的情況下播放這些視頻,即從SD卡播放。這裏來的問題是如何獲得各自產品的特定視頻路徑。我不必打開畫廊。我必須直接播放該產品的視頻。以及如何限制多次視頻下載。 我播放視頻的代碼是如何從SD卡播放視頻
private void playVideo(String path) {
dialog = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar);
dialog.setContentView(R.layout.layout_video_popup);
ImageView imgViewClose = (ImageView)dialog.findViewById(R.id.imgViewClose);
imgViewClose.setOnClickListener(this);
btnPlayPause = (Button) dialog.findViewById(R.id.button1);
btnPlayPause.setOnClickListener(this);
seekBar = (SeekBar) dialog.findViewById(R.id.seekBar1);
seekBar.setOnClickListener(this);
linearlayout = (LinearLayout) dialog.findViewById(R.id.linerlayout_bottom);
mVideoView = (VideoView)dialog.findViewById(R.id.videoView);
mVideoView.setOnTouchListener(this);
mVideoView.setOnPreparedListener(this);
mVideoView.setOnCompletionListener(this);
dialog.show();
playVideo(path, mVideoView);
AppLog.d("Video", "playVideo()", path);
}
private void playVideo(String path, VideoView mVideoView) {
if(path == null || path.isEmpty()) {
return;
}
try {
pDialpg = ProgressDialog.show(this, "Video", "Please wait..", false, true);
mVideoView.setVideoPath(path);
mVideoView.requestFocus();
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
relativeParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
relativeParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
mVideoView.setLayoutParams(relativeParams);
mVideoView.invalidate();
} catch (Exception e) {
// TODO: handle exception
}
請參閱此鏈接:http://stackoverflow.com/questions/10083609/playing-video-from-sd-card – krishna 2013-04-11 10:37:45
這些提供了特定視頻的鏈接。我的問題是別的 – Avinash 2013-04-11 10:41:15