Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7657231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:58:30+00:00 2026-05-31T12:58:30+00:00

I have an AsyncTask, where I hide a video view, start the video playback,

  • 0

I have an AsyncTask, where I hide a video view, start the video playback, and show the video view when the video is playing.

But the video would just not start when the video view is set to invisible, the async task keeps hanging in onBackground. If I comment out this line, the video starts playing.
Why does the video view require a visible surface?

public void walk(final View v) {

    new AsyncTask() {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            mVideoView.setVisibility(View.INVISIBLE); // this line causes video not to start
            mVideoView.start();
        }

        @Override
        protected Object doInBackground(Object... objects) {
            while (!mVideoView.isPlaying()) {}
            return null;
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);
            mVideoView.setVisibility(View.VISIBLE);
        }

    }.execute();

A bit of background why I’m doing this: I try to avoid the well-known issue of the black flash that you usually have when starting a video:

https://stackoverflow.com/search?q=%5Bandroid%5D+videoview+black

https://stackoverflow.com/search?q=%5Bandroid%5D+video+%5Bmediaplayer%5D+black

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:58:31+00:00Added an answer on May 31, 2026 at 12:58 pm

    The VideoView is really a specialised SurfaceView. A SurfaceView works by creating another window behind the normal window (containing all of the views), and then having an area of transparency so that the new window (with its own drawing surface) can be seen behind it.

    If a SurfaceView is no longer visible, its surface will be destroyed i.e. SurfaceHolder.Callback.surfaceDestroyed is called. The VideoView will not try to play its video if there is not a valid surface, hence your AsyncTask will be able to never leave doInBackground.

    The Surface will be created for you while the SurfaceView’s window is visible; you should implement surfaceCreated(SurfaceHolder) and surfaceDestroyed(SurfaceHolder) to discover when the Surface is created and destroyed as the window is shown and hidden.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following asynctask class which is not inside the activity. In the
I have an AsyncTask which is executed just before my application quits. It gets
I have an asynctask of which's onPostExecute i am calling a function to show
I have an AsyncTask that retrieves information from the internet. But when signal or
I have AsyncTask and my progress in background is in infinite loop. But I
I have a asynctask that I cancel when the view is destoried via onDestoryView().
I have some AsyncTask that loads a video stream into the player, so I
I have an AsyncTask with a textview loaded in the class so it looks
My goal is to have an AsyncTask that can execute multiple times (one task
I have 30 threads (AsyncTask) executed in the same time. Before execute them, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.