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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:19:14+00:00 2026-05-16T14:19:14+00:00

I have a simple mp3 playing through AVAudioPlayer and I want to be able

  • 0

I have a simple mp3 playing through AVAudioPlayer and I want to be able to display how much time is left.

I know the answer includes subtracting AVAudioPlayer.duration from AVAudioPlayer.currentTime but I don’t know how to implement a function which calculates it while it’s playing (like an onEnterFrame in Actionscript I guess). At present currentTime is static, i.e. zero.

  • 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-16T14:19:15+00:00Added an answer on May 16, 2026 at 2:19 pm

    I would go for an NSTimer. Schedule it to run every second while the media is played and so you can keep your UI updated with the time left.

    // Place this where you start to play
    NSTimer * myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                                         target:self
                                                       selector:@selector(updateTimeLeft)
                                                       userInfo:nil
                                                        repeats:YES];
    

    And create the method to update you UI:

    - (void)updateTimeLeft {
        NSTimeInterval timeLeft = self.player.duration - self.player.currentTime;
    
        // update your UI with timeLeft
        self.timeLeftLabel.text = [NSString stringWithFormat:@"%f seconds left", timeLeft];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple HTTP server running that pretty much just serves an MP3
Simple enough... I have a background song playing on my game, and I would
I'm making a simple MP3Player in Java. I have managed to play a .mp3
I have a simple button that plays a small MP3 file, looping it 30
Possible Duplicate: Building a simple mp3 music player I want to create simplest mp3
I have a simple Python program that gets artwork from MP3 files. But when
I have simple table in Sybase -- Creating table 'SimpleText' CREATE TABLE [dbo].[SimpleText] (
I have simple class with width and height member fields which define number of
I have simple php validation form that is halfway working. If you leave the
I have simple JavaScript snippet: var obrazek = [{nazwa: "Sniadanie", wiek: 100, autor: "Alicja"},{nazwa:

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.