Search code examples
androidvideoopacityinvisible

Hide video but have it continue to play


I have an image and a video player. In portrait, it shows both. Doing landscape left, just the video shows. Doing landscape right just the image shows.

I am using the setVisibility() method right now to achieve that. The problem with doing:

myVideoView.setVisibility(View.INVISIBLE);

causes the video to stop playing. Is there a way to keep it playing but also not visible to the user? Maybe like set the opacity of the VideoView to 0?


Solution

  • I think I found a solution here. In order to make videoview invisible and keep it playing sound you simply hide it by setting alpha value.

    mVideoView.setAlpha(0f);
    

    Hope it works for you!