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

  • Home
  • SEARCH
  • 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 3227858
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:37:26+00:00 2026-05-17T16:37:26+00:00

I have some AsyncTask that loads a video stream into the player, so I

  • 0

I have some AsyncTask that loads a video stream into the player, so I want to show some Loading screen while it performs. Currently my onCreate code looks like this:

final View loadingView = getLayoutInflater().inflate(R.layout.video_loading, null);
final View playerView = getLayoutInflater().inflate(R.layout.player, null);
final VideoView videoView = (VideoView) playerView.findViewById(R.id.canvas);

Log.d(TAG, "Running video player for video " + videoId);

new VideoPlayingTask(this, videoView.getHolder()) {

    protected void onPreExecute() {
        setContentView(loadingView);
        super.onPreExecute(); // it creates or re-uses (resetting it before)
                            // MediaPlayer instance inside and sets display using setDisplay to the passed holder
    };

    protected void onPostExecute(FileInputStream dataSource) {

        setContentView(playerView);
        videoView.requestFocus();
        super.onPostExecute(dataSource); // it sets data source, 
                                        // prepares player and starts it
    };

 }.execute(videoId);

loadingView is displayed properly, then when changing content to playerView, screen goes black, but sound plays properly in background.

I get these two warnings from MediaPlayer in the logs:

info/warning (1, 35)
info/warning (1, 44)

I’ve tried to use ViewSwither and to call showNextView inside onPostExecute, but the behavior was similar, black screen when changing to videoView.

I’ve tried the way with two inner layouts laying inside current and switch their visibility manually, and this also not helped to me.

When I use just single VideoView in this activity, it works perfectly and shows both image and sound.

video_loading.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"               
              android:gravity="center">
    <ProgressBar android:layout_width="@dimen/small_progress_side"
                 android:layout_height="@dimen/small_progress_side" />
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="5dp"
              android:text="@string/caching_video" />
</LinearLayout>

player.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <VideoView android:id="@+id/canvas"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent" />
</LinearLayout> 

this question seems a little bit similar, but switching loadingView visibility to INVISIBLE does not work in my case.

  • 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-17T16:37:26+00:00Added an answer on May 17, 2026 at 4:37 pm

    I’ve just used ProgressDialog.show() instead of flipping views, it is a lot simpler and VideoView handles it right.

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

Sidebar

Related Questions

I have some UI in VB 2005 that looks great in XP Style, but
We have some input data that sometimes appears with &nbsp characters on the end.
I have some kind of test data and want to create a unit test
We have some files on our website that users of our software can download.
I have some ASP.NET web services which all share a common helper class they
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some classes layed out like this class A { public virtual void
I have some C# / asp.net code I inherited which has a textbox which
I have some code like this in a winforms app I was writing to
I have some strings of xxh:yym format where xx is hours and yy is

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.