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

The Archive Base Latest Questions

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

AVPlayer is fully customizable, unfortunately there are convenient methods in AVPlayer for showing the

  • 0

AVPlayer is fully customizable, unfortunately there are convenient methods in AVPlayer for showing the time line progress bar.

AVPlayer *player = [AVPlayer playerWithURL:URL];
AVPlayerLayer *playerLayer = [[AVPlayerLayer playerLayerWithPlayer:avPlayer] retain];[self.view.layer addSubLayer:playerLayer];

I have an progress bar that indicates the how video has been played, and how much remained just as like MPMoviePlayer.

So how to get the timeline of video from AVPlayer and how to update the progress bar

Suggest me.

  • 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-27T21:46:15+00:00Added an answer on May 27, 2026 at 9:46 pm

    Please use the below code which is from apple example code “AVPlayerDemo”.

        double interval = .1f;  
    
        CMTime playerDuration = [self playerItemDuration]; // return player duration.
        if (CMTIME_IS_INVALID(playerDuration)) 
        {
            return;
        } 
        double duration = CMTimeGetSeconds(playerDuration);
        if (isfinite(duration))
        {
            CGFloat width = CGRectGetWidth([yourSlider bounds]);
            interval = 0.5f * duration / width;
        }
    
        /* Update the scrubber during normal playback. */
        timeObserver = [[player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(interval, NSEC_PER_SEC) 
                                                              queue:NULL 
                                                         usingBlock:
                                                          ^(CMTime time) 
                                                          {
                                                              [self syncScrubber];
                                                          }] retain];
    
    
    - (CMTime)playerItemDuration
    {
        AVPlayerItem *thePlayerItem = [player currentItem];
        if (thePlayerItem.status == AVPlayerItemStatusReadyToPlay)
        {        
    
            return([playerItem duration]);
        }
    
        return(kCMTimeInvalid);
    }
    

    And in syncScrubber method update the UISlider or UIProgressBar value.

    - (void)syncScrubber
    {
        CMTime playerDuration = [self playerItemDuration];
        if (CMTIME_IS_INVALID(playerDuration)) 
        {
            yourSlider.minimumValue = 0.0;
            return;
        } 
    
        double duration = CMTimeGetSeconds(playerDuration);
        if (isfinite(duration) && (duration > 0))
        {
            float minValue = [ yourSlider minimumValue];
            float maxValue = [ yourSlider maximumValue];
            double time = CMTimeGetSeconds([player currentTime]);
            [yourSlider setValue:(maxValue - minValue) * time / duration + minValue];
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any delegate methods in AVPlayer class? I need to handle interruptions such
I have implemented a custom movie player with AVPlayer . On setting the value
I'm playing music with an AVPlayer . Now at a certain time a NSTimer
Is there any way to support AirPlay with AVPlayer ? I know it can
I have an audio player that I'm building using AVPlayer. Currently, I keep the
I am doing audio playback using the AVPlayer class from a remote URL. It
I have implemented audio playback using AVPlayer, playing a remote mp3 url. I want
I have an instance of AVPlayer in my application. I use the time boundary
Is there a way to know whether an AVPlayer playback has stalled or reached
I'm currently writing a custom video player using AVPlayer. The video plays fine and

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.