0

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;
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
ConcealedREPO
  • 31
  • 1
  • 6
  • 1
    Please could you post the full error you get? – Simon Crane Sep 27 '19 at 12:56
  • I hope you are using the format of videos as 3gp, wmv or mp4 and named with lower case, numerics, underscores and dots in its filename likewise:video_file.mp4. – Arun Kumar Sep 28 '19 at 08:55
  • R.raw.verb is a number so you are passing a something in the content that end as a number – cutiko Oct 01 '19 at 23:51
  • Possible duplicate of [Android - How to get Uri from raw file?](https://stackoverflow.com/questions/16791439/android-how-to-get-uri-from-raw-file) – cutiko Oct 01 '19 at 23:52

0 Answers0