I have been trying to include Videos in list view but the videos cannot be played due to error in IOException. I've tried changing the video content and yet I still get the same result
The array that contains the text and the video path
String[] phraVideos ={
"android.resource://com.example.signit" + "/" + R.raw.verbs,
"android.resource://com.example.signit" + "/" + R.raw.eat
};
String[] phraText = {
"verbs",
"eat"
};
The modal class
package com.example.signit;
public class PhraseModel {
private String phraVideo;
private String phraText;
public PhraseModel(String phraVideo, String phraText) {
this.phraVideo = phraVideo;
this.phraText = phraText;
}
public String getPhraVideo() {
return phraVideo;
}
public void setPhraVideo(String phraVideo) {
this.phraVideo = phraVideo;
}
public String getPhraText() {
return phraText;
}
public void setPhraText(String phraText) {
this.phraText = phraText;
}
}
The custom adapter that I use and the error is in here(I assume)
public class PhraseAdapter extends BaseAdapter implements Filterable {
Context context;
ArrayList <PhraseModel> phraseModels; // data source
CustomeFilter filter;
ArrayList<PhraseModel> filterList;
public PhraseAdapter(Context context, ArrayList<PhraseModel> phraseModels) {
this.context = context;
this.phraseModels = phraseModels;
this.filterList = phraseModels;
}
@Override
public int getCount() {
return phraseModels.size();
}
@Override
public Object getItem(int position) {
return phraseModels.get(position); // return the position for a
single object
}
@Override
public long getItemId(int position) {
return phraseModels.indexOf(getItem(position));
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater =(LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(convertView == null){
convertView = inflater.inflate(R.layout.phrasedisplaylist,null);
}
TextView contentText = (TextView)
convertView.findViewById(R.id.contentText);
VideoView contentVideo= (VideoView)
convertView.findViewById(R.id.contentVideo);
//Set data to the views
contentText.setText(phraseModels.get(position).getPhraText());
String videoPath = phraseModels.get(position).getPhraVideo();
Uri uri = Uri.parse(videoPath);
contentVideo.setVideoURI(uri);
contentVideo.start();
return convertView;
}