我無法播放來自SD卡的視頻文件。 - 我正在播放來自SD卡的特定視頻文件。 - 同時從列表中選擇視頻,它不會播放視頻。 - 我傳遞給videoView類的意圖是無法讀取。SD卡視頻不播放?
public class AndroidThumbnailList extends ListActivity{
String[] videoFileList = {
"/sdcard/Periodontal/Perio-Probling.mp4",
"/sdcard/Periodontal/Inlays.mp4"
/* "/sdcard/Video/Onlays.mp4",
"/sdcard/Video/Root Canal Treatment.mp4",
"/sdcard/Video/crown4.mp4",
"/sdcard/Video/crown5.mp4",
"/sdcard/Video/crown6.mp4",
"/sdcard/Video/crown7.mp4"*/
};
public class MyThumbnaildapter extends ArrayAdapter<String>{
public MyThumbnaildapter(Context context, int textViewResourceId,
String[] objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View row = convertView;
if(row==null){
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.row, parent, false);
}
row.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
if(position==0)
{
Intent intent = new Intent(AndroidThumbnailList.this, ViewVideo.class);
intent.putExtra("videofilename", videoFileList);
startActivity(intent);
}
/*if(position==1)
{
Intent intent = new Intent(mContext, PeriodontalCare.class);
mContext.startActivity(intent);
}
if(position==2)
{
Intent i = new Intent(mContext, CosmeticCare.class);
mContext.startActivity(i);
}*/
}
});
TextView textfilePath = (TextView)row.findViewById(R.id.FilePath);
textfilePath.setText(videoFileList[position]);
ImageView imageThumbnail = (ImageView)row.findViewById(R.id.Thumbnail);
Bitmap bmThumbnail;
bmThumbnail = ThumbnailUtils.createVideoThumbnail(videoFileList[position], Thumbnails.MICRO_KIND);
imageThumbnail.setImageBitmap(bmThumbnail);
return row;
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new MyThumbnaildapter(AndroidThumbnailList.this, R.layout.row, videoFileList));
}
}
我VideoView類:
public class ViewVideo extends Activity {
private String videoFileList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.videofile);
// mVideoView = (VideoView) findViewById(R.id.surface_view);
System.gc();
Intent i = getIntent();
Bundle extras = i.getExtras();
videoFileList = extras.getString("videofilename");
VideoView vv = new VideoView(getApplicationContext());
setContentView(vv);
vv.setVideoPath(videoFileList);
vv.setMediaController(new MediaController(this));
vv.requestFocus();
vv.start();
}
}
不會對電網項目使用onClickListener。使用網格視圖提供的onItemSelected(或其他)。因爲你的行對象被重用。 – njzk2 2012-03-13 09:25:52