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 8314425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:48:56+00:00 2026-06-08T20:48:56+00:00

I have a VideoView and a TextView on the same activity. Here s the

  • 0

I have a VideoView and a TextView on the same activity. Here s the xml for the layout.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rellayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <VideoView
        android:id="@+id/videoview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:padding="5dp" />
    <TextView 
        android:id="@+id/numberTicker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/purple"
        android:textStyle="bold"
        android:gravity="top|right"
        android:textSize="35dp"
        android:maxEms="3"/>
</RelativeLayout>

As soon as the video start playing I wish to display a number on the numberTicker text view. Mind you the numbers are likely to change 4 times per second. Anyway, the primary issue I have is to identify that the video has started playing and to keep updating the TextView.

My attempt :

vid = (VideoView) findViewById(R.id.videoview);
ratings = (TextView) findViewById(R.id.ratingTicker);
vid.setOnPreparedListener(new OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mp) {
                vid.start();
                vid.postDelayed(onEveryQuarterSecond,250);
            }
        });
...
...
    private Runnable onEveryQuarterSecond = new Runnable() {

        Random r = new Random();
        int uVal, aVal;

        @Override
        public void run() {
            ratings.setText(Integer.toString(r.nextInt()));

        }
    };

The code Runnable would only run once, and never get updated.
Am I missing something?

Thanks for the help!

  • 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-06-08T20:48:58+00:00Added an answer on June 8, 2026 at 8:48 pm

    You get a MediaPlayer object in onPrepared(). You could use that like this:

    vid.setOnPreparedListener(new OnPreparedListener() {
    
            @Override
            public void onPrepared(MediaPlayer mp) {
                this.mediaPlayer = mp; //have mediaPlayer be a class variable
                vid.start();
                vid.postDelayed(onEveryQuarterSecond,250);
            }
        });
    
     private Runnable onEveryQuarterSecond = new Runnable() {
    
        Random r = new Random();
        int uVal, aVal;
    
        @Override
        public void run() {
            while(mediaPlayer.isPlaying()) {
                 ratings.setText(Integer.toString(r.nextInt()));
                 Thread.sleep(250);
            }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity whose layout only contains a VideoView. Here is the xml:
i have a videoview in my application. the code is like this. <?xml version=1.0
I have an app that displays a video using VideoView. The layout consists of
In my application, I have an activity play http live streaming video in landscape
I am using the merge layout to have my TextView appear on top of
n00b here (first Android project). I have been given a custom video codec that
UPDATE : Got a reply from Google that it isn't possible: http://code.google.com/p/android/issues/detail?id=11752&can=1&q=videoview&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars This should
I have a VideoView that takes up the top half of the Activity in
I have the following code in my activity. In my xml, the video view
I have an activity that has a VideoView widget that plays a mp4 file,

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.