Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video is not showing on VideoView but I can hear its sound

  • On my button click I wrote the following code for playing video from my SDCARD (mp4).

    video_view = (VideoView)findViewById(R.id.video_view);
    video_view.setVideoPath("/sdcard/myvideo.mp4");
    video_view.setMediaController(new MediaController(this));
    video_view.start(); 
    
  • I can play recorded video from SDCARD in player.

  • But when I run it on my application in videoview I can hear only sound.
  • Problem : I am not able to see the video.

---- I tried following SO link but still no luck ----

  • link 1
  • link 2

  • Is anybody ever faced this kind of problem ? If yes then how can it solve it ?

like image 359
Dhruvil Patel Avatar asked Oct 29 '13 05:10

Dhruvil Patel


3 Answers

I've tried every method above, but none of them could work.

Finally, I tried to call this function, then the video appeared.

video_view.setZOrderOnTop(true);

Hope this also works for you.

like image 123
SeaStar Avatar answered Feb 23 '23 06:02

SeaStar


SOLUTION 1:

videoView.setZOrderOnTop(true);

this will set the videoview to the top layer; In other words: block everything under it.

SOLUTION 2:

videoView.setBackgroundColor(Color.TRANSPARENT);

SOLUTION 3:

sometimes this is related about your apptheme; In my case, I changed the apptheme from @style/AppTheme to @android:style/Theme.NoTitleBar.Fullscreen fix my problem.

like image 41
liu zhiyuan Avatar answered Feb 23 '23 05:02

liu zhiyuan


try this :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <VideoView 
        android:id="@+id/view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

it may be help you...

like image 20
Harshit Rathi Avatar answered Feb 23 '23 06:02

Harshit Rathi