Hello, I have CardView and VideoView u MediaController built in there, but with a preview, it displays only a black screen, how can I display a preview ??

<android.support.v7.widget.CardView android:id="@+id/card_view" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" card_view:cardBackgroundColor="@color/colorCard" card_view:cardCornerRadius="10dp" card_view:cardElevation="5dp" card_view:cardUseCompatPadding="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <VideoView android:layout_width="match_parent" android:layout_height="200dp" android:id="@+id/videoView" /> <MediaController android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/mediaController" /> <TextView android:id="@+id/textViewName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|center_horizontal" android:layout_marginTop="10dp" android:text="Android Name" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="@color/primary_text_default_material_light" android:layout_marginLeft="16dp" /> <TextView android:id="@+id/textViewVersion" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|center_horizontal" android:layout_marginTop="10dp" android:text="Android Version" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/primary_text_default_material_light" android:layout_marginLeft="16dp" /> </LinearLayout> </android.support.v7.widget.CardView> 

    1 answer 1

    Do not use the preview. If the device / emulator works, then everything is fine. The preview will not be able to download and display something from the network.

    • But it works with lags, then it loads no video, the media monitor can be displayed immediately from 2 videos. Or is it better to write your meyplayer using the MediaPlayer class ??? - Dmitriy Dev
    • The problem can be anywhere. On the server side or in your code or device, a low-power or old OS or custom firmware / launcher. I somehow tried to display the video by reference and there were no problems. In any case, the problem is in the layout of the screen. - Yuriy SPb
    • Android 5.1, I have 11 videos on my card at once, maybe that's why it is dumb ?? Maybe there is another way to implement ??? - Dmitriy Dev
    • @DmitryKoverko, i.e. in one markup, at the same time 11 videos start to play on the screen? .. Yes, this is a very resource-intensive operation. Better not to try more than one video at a time to play. On the other hand, I don’t see VideoView 11 in your markup ... - Yuriy SPb
    • No, the video doesn’t play right away, but it starts to load, but I don’t have them in the markup, why? I use cardview and create a sheet from the cards ??? Perhaps this is the reason it will be. - Dmitriy Dev