How to automatically play video in listview on android app

大城市里の小女人 提交于 2019-12-07 05:17:08

问题


I want to play video in listview from online server as like VINE app. And plays only one video at a time.But videoview cann't show in listview. I can view all others like text, links. But VideoView cann't show in listview row. show all without videoview. when try without listview it works fine and play video from online my listview adapter code snippet like this:

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();

layout row of listview:

<?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>

来源:https://stackoverflow.com/questions/24139568/how-to-automatically-play-video-in-listview-on-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!