Reputation: 249
Something strange here, I am trying to play a video from a listview but the problem is the videoView is not even placed in the list. the stranger part is that I managed to do it twice before without any problem but now can't... And I deleted the previous scripts... here the script:
public class Dadapt extends BaseAdapter {
public int play = 0;
long timeWhenStopped = 0;
private String SOURCE = "source track";
// Declare Variables
Context context;
LayoutInflater inflater;
LayoutInflater flat;
ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
LoaderImage conteloader;
Audio_load audio_load;
ImageView im;
VideoView video;
AlertDialog.Builder builder;
HashMap<String, String> resultp = new HashMap<String, String>();
AQuery aq;
MediaController mc;
public Dadapt(Context context, ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
mc = new MediaController(context);
video = new VideoView(context);
imageLoader = new ImageLoader(context);
aq = new AQuery(context);
builder = new AlertDialog.Builder(context);
// TODO Auto-generated constructor stub
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return data.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final TextView friend;
final String type, vids;
final LinearLayout lin;
final ImageView avatar;
final TextView name;
final Button mess;
final VideoView vid;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.event_list, parent, false);
resultp = data.get(position);
vid = (VideoView)itemView.findViewById(R.id.deo);
type = resultp.get(Me.TYPE);
vids ="http://xxxxxxx.com/" + resultp.get(Me.MEDIA);
lin = (LinearLayout) itemView.findViewById(R.id.near);
avatar = (ImageView) itemView.findViewById(R.id.event_pic);
if (type.equalsIgnoreCase("video")) {
mc.setMediaPlayer(vid);
vid.setMediaController(mc);
vid.setVideoPath(vids);
vid.start();
} else {
imageLoader.DisplayImage3(
"http://xxxxxxxx/" + resultp.get(Me.MEDIA), avatar);
}
friend = (TextView) itemView.findViewById(R.id.event_title);
friend.setText(resultp.get(Me.NAME));
name = (TextView) itemView.findViewById(R.id.event_descr);
name.setText(resultp.get(Me.DESCRIPTION));
return itemView;
}
}
What am I doing wrong? The strangest part is that I done it previously twice so maybe a small error I made here...
It is like the videoview doesn't even show at all
Edit
here the XML code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="@android:drawable/toast_frame"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:id="@+id/near"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:padding="5dp"
android:paddingTop="0dp" >
<ImageView
android:id="@+id/event_pic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp" />
<VideoView
android:id="@+id/deo"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/event_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#777777"
android:textStyle="italic" />
<TextView
android:id="@+id/event_descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textAlignment="inherit" />
<Button
android:id="@+id/event_go"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/show_me"
android:textColor="#777777" />
</LinearLayout>
on the logcat I see: 12-04 21:12:51.980: D/AbsListView(10157): unregisterIRListener() is called
Upvotes: 1
Views: 1686
Reputation: 249
Well, after digging around, it appear that you just can not put a videoView inside a listView so I did a litle trick, I just put a gridView with just one column and that did the trick
Upvotes: 2