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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:58:09+00:00 2026-05-29T16:58:09+00:00

I have a MediaPlayer playing a file, and I want to continuously write logging

  • 0

I have a MediaPlayer playing a file, and I want to continuously write logging data in the background. This should be done by a Thread (or a similar concept, but I don’t know if an AsyncTask is the way to go here). The Thread shouldn’t always write, but pause for half a second in between.

My MediaPlayer works fine, but once I try to run my Thread, no video is displayed. The Thread appears to be running though.

Here’s the relevant code:

Thread:

public class LoggingThread implements Runnable {
String videoName;

public LoggingThread(String videoName) {
    Logger.startContinuousLogCSV(videoName);
    Log.d(TAG, "Created logging thread");
}

public void run() {
    Log.d(TAG, "Trying to run the thread");
    try {
        while (mIsVideoPlaying) {
            Log.d(TAG, "Video is playing. Writing rating to file.");
                    // write to file and Thread.sleep(500)
                    // problem occurs regardless of this
        }
        Log.d(TAG, "Video not playing anymore, stopping thread.");
    } catch (Exception e) {
        Logger.closeContinuousLogCSV();
    }
}
}

MediaPlayer start:

Here’s where I prepare the player for a video and create the Thread instance.

public void preparePlayerForVideo(int videoIndex) {
  Log.d(TAG, "Creating new logging thread");
  mLoggingThread = new LoggingThread(Session.sTracks.get(videoIndex));

  mPlayer = new MediaPlayer();
  // various calls to set up player, this works fine
  mPlayer.setOnPreparedListener(this);
  mPlayer.prepare();
}

This is called from the onPreparedListener.

public void startVideo() {
  mIsVideoPlaying = true;
  mLoggingThread.run();
  mPlayer.start();
}

LogCat output:

From the output, it appears that the Thread is running fine, but why is the player not showing any video?

02-15 12:00:18.904: D/SubjectivePlayerSession(17918): Creating new logging thread
02-15 12:00:18.944: D/SubjectivePlayerSession(17918): Created logging thread
02-15 12:00:18.944: D/SubjectivePlayerSession(17918): Set data source to: /mnt/sdcard/SubjectiveMovies/pair_01-video_a-GUT_DEUTSCH.mp4
02-15 12:00:19.095: V/SubjectivePlayerSession(17918): onVideoSizeChanged called
02-15 12:00:19.095: D/SubjectivePlayerSession(17918): Running thread
02-15 12:00:19.095: D/SubjectivePlayerSession(17918): Trying to run the thread
02-15 12:00:19.095: D/SubjectivePlayerSession(17918): Video is playing. Writing rating to file.
02-15 12:00:19.605: D/SubjectivePlayerSession(17918): Video is playing. Writing rating to file.
...
  • 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-29T16:58:14+00:00Added an answer on May 29, 2026 at 4:58 pm

    You should start a Thread object and add your Runnable to it:

    public void startVideo() {
      mIsVideoPlaying = true;
      new Thread(mLoggingThread).start();
      mPlayer.start();
    }
    

    Calling Runnable#run() will run the code on the current thread, instead of creating a new one.

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

Sidebar

Related Questions

I have a strange problem when playing music files with the mediaplayer. The playback
i have a video playing with MediaPlayer , ok on iPad, but if I
I recently observed a very weird problem with MediaPlayer playing an mp3 file. I'm
I have a problem with playing video in mediaplayer. I have a sound but
In my android game I want to have a rhythm Mediaplayer object and a
I have a mediaplayer that can only read samba shared files. I would like
i have windows media player in my application.i want to allow only the supported
I have the following code: AssetFileDescriptor afd = getAssets().openFd(AudioFile.mp3); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor());
I'm trying to write to an AVI file using AVIStreamWrite but the resulting avi
I have my mp3 file in byte[] (downloaded from an service) and I would

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.