如何在Android应用程序的listview中自动播放视频

New*_*ton 5 android-videoview

我想从在线服务器播放listview中的视频,就像VINE app一样.并且一次只播放一个视频.但是视频视图无法在列表视图中显示.我可以查看所有其他文本,链接.但VideoView无法在listview行中显示.显示所有没有videoview.当尝试没有listview它工作正常并从在线播放视频我的listview适配器代码片段,如下所示:

mViewHolder.mVideoView.setVisibility(View.VISIBLE);
MediaController mComtroller = new MediaController(mContext);
mViewHolder.mVideoView.setMediaController(mComtroller);
mViewHolder.mVideoView.setVideoURI(Uri.parse("myLink"));
mViewHolder.mVideoView.start();
mViewHolder.mVideoView.requestFocus();
Run Code Online (Sandbox Code Playgroud)

列表视图的布局行:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:weightSum="100" >
        <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_margin="5dp"
        android:layout_weight="80"
        android:weightSum="10"
        android:orientation="horizontal"
        android:background="@drawable/background" >
            <VideoView
            android:id="@+id/vv_surface_view"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:visibility="visible"
            android:layout_weight="5" />
        <ImageView
            android:id="@+id/iv_videoThumbnail"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="5"
            android:background="@drawable/background" />
    </LinearLayout>

    <TextView
        android:id="@+id/tv_VideoName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="10"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:layout_weight="10" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)