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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:46:10+00:00 2026-05-15T17:46:10+00:00

The function below is part of the code for Google’s Camera app. I didn’t

  • 0

The function below is part of the code for Google’s Camera app. I didn’t understand the logic of the statements in bold. Please help.

int seconds = intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0);
mMaxVideoDurationInMs = 1000 * seconds;

mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);

//this function is to update the recording time

private void updateRecordingTime() {
if (!mMediaRecorderRecording) {
return;
}
long now = SystemClock.uptimeMillis();
long delta = now – mRecordingStartTime;

    // Starting a minute before reaching the max duration
    // limit, we'll countdown the remaining time instead.
    boolean countdownRemainingTime = (mMaxVideoDurationInMs != 0
            && delta >= mMaxVideoDurationInMs - 60000);

    long next_update_delay = 1000 - (delta % 1000);
    long seconds;
    if (countdownRemainingTime) {
        **delta = Math.max(0, mMaxVideoDurationInMs - delta);
        seconds = (delta + 999) / 1000;**
    } else {
        **seconds = delta / 1000; // round to nearest**
    }

    long minutes = seconds / 60;
    long hours = minutes / 60;
    long remainderMinutes = minutes - (hours * 60);
    long remainderSeconds = seconds - (minutes * 60);

    String secondsString = Long.toString(remainderSeconds);
    if (secondsString.length() < 2) {
        secondsString = "0" + secondsString;
    }
    String minutesString = Long.toString(remainderMinutes);
    if (minutesString.length() < 2) {
        minutesString = "0" + minutesString;
    }
    String text = minutesString + ":" + secondsString;
    if (hours > 0) {
        String hoursString = Long.toString(hours);
        if (hoursString.length() < 2) {
            hoursString = "0" + hoursString;
        }
        text = hoursString + ":" + text;
    }
    mRecordingTimeView.setText(text);

    if (mRecordingTimeCountsDown != countdownRemainingTime) {
        // Avoid setting the color on every update, do it only
        // when it needs changing.
        mRecordingTimeCountsDown = countdownRemainingTime;

        int color = getResources().getColor(countdownRemainingTime
                ? R.color.recording_time_remaining_text
                : R.color.recording_time_elapsed_text);

        mRecordingTimeView.setTextColor(color);
    }

    // Work around a limitation of the T-Mobile G1: The T-Mobile
    // hardware blitter can't pixel-accurately scale and clip at the
    // same time, and the SurfaceFlinger doesn't attempt to work around
    // this limitation. In order to avoid visual corruption we must
    // manually refresh the entire surface view when changing any
    // overlapping view's contents.
    mVideoPreview.invalidate();
    mHandler.sendEmptyMessageDelayed(
            UPDATE_RECORD_TIME, next_update_delay);
}
  • 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-15T17:46:11+00:00Added an answer on May 15, 2026 at 5:46 pm

    Are you referring to these lines?

    1.        delta = Math.max(0, mMaxVideoDurationInMs - delta);
    2.        seconds = (delta + 999) / 1000;
    

    and

    3.        seconds = delta / 1000; // round to nearest
    

    It’s hard to tell exactly, as nothing was bold in your question (but the ** before and after these lines makes me think that’s what you’re referring to).

    delta is in milliseconds, of which there are 1000 in a second.

    Line 1: Ensures a 0 is shown instead of a negative number

    Line 2: Rounds up to the nearest second. Since seconds is an integer, any value of delta from 1001 (1s 1ms) to 1999 (1s, 999ms) would be returned as seconds = 2.

    Line 3: Simply drops the ms portion, so delta = 1 returns 0, but so does delta = 999.


    Delta means “change in” as in the amount of time change.

    The two are almost the same, but when the code is displaying seconds remaining, it chooses to round up so that, e.g. 1.5s (1500ms) remaining is displayed as 1 second.

    When it’s counting seconds elapsed, it rounds down, so that, e.g. 1.5s (1500ms) elapsed is displayed as 1s.

    Since seconds is an int, any floating point number will have the decimal portion chopped off. So:

    1500 / 1000 = 1.500
    (int)1.500 = 1
    

    When you add the 999 you instead have:

    (1500 + 999) / 1000 = 2499 / 1000 = 2.499
    (int)2.499 = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The function below is part of the code for Google's Camera app. It is
The part I don't understand in the code below is function(serialized). I know change
The excerpt below is part of a .ajax() function I'm using to pull data
what is the problem in the code part below? Any ideas? I m sending
Code below is part of cart66 WordPress plugin's php file. When I list options
New Google Analytics code looks like one below: <script type=text/javascript> var _gaq = _gaq
I am very new to jQuery. Below is part of my code <div class
My function below, will take the values from my custom meta fields (after a
My function below calls a partial view after a user enters a filter-by string
I have the function below. It gets the values from checked boxes and transfer

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.