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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:04:23+00:00 2026-06-06T08:04:23+00:00

I am using AVPlayer to stream some live HTTP audio, not AVAudioPlayer which does

  • 0

I am using AVPlayer to stream some live HTTP audio, not AVAudioPlayer which does not support live HTTP audio streaming, the question is, how do I get the status of current playback? For example:

Tap Play Button -> [Loading] -> [Playing]
Tap Pause Button -> [Paused]

I need to show a spinner when loading, show a pause button when playing and show a play button when paused, I know I can observe the ‘status’ and ‘rate’ properties of AVPlayer:

rate:
the current rate of playback. 0.0 means “stopped”, 1.0 means “play at the natural rate of the current item”.

status:
Indicates whether the player can be used for playback.

AVPlayerStatusUnknown,
AVPlayerStatusReadyToPlay,
AVPlayerStatusFailed

so there is no way to indicate the audio is “LOADING”, and after the status changes to AVPlayerStatusReadyToPlay, it still takes some time to have the audio playing(maybe because it is a live audio).

But anyway, how do I get the correct status of current playback? I know there is an AudioStream from Matt, but it does not support HTTP Live audio.

Thanks very much!

  • 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-06T08:04:27+00:00Added an answer on June 6, 2026 at 8:04 am

    I used

        [self.mPlayerItem addObserver:self 
                       forKeyPath:kStatusKey 
                          options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
                          context:AVPlayerDemoPlaybackViewControllerStatusObservationContext];
    

    to monitor the status key (“status”). Then I created the player

    [self setPlayer:[AVPlayer playerWithPlayerItem:self.mPlayerItem]];  
    

    And in the observeValueForKeyPath

        if (context == AVPlayerDemoPlaybackViewControllerStatusObservationContext)
    {        
        AVPlayerStatus status = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
        switch (status)
        {
                /* Indicates that the status of the player is not yet known because 
                 it has not tried to load new media resources for playback */
            case AVPlayerStatusUnknown:
            {
                [lblvalidation setText:@"Loading..."];
    
                NSLog(@"AVPlayerStatusUnknown");
            }
                break;
    
            case AVPlayerStatusReadyToPlay:
            {
                /* Once the AVPlayerItem becomes ready to play, i.e. 
                 [playerItem status] == AVPlayerItemStatusReadyToPlay,
                 its duration can be fetched from the item. */
    
                NSLog(@"AVPlayerStatusReadyToPlay");
    
                [self.player play];
                [lblvalidation setText:@"Playing..."];
            }
                break;
    
            case AVPlayerStatusFailed:
            {
                [lblvalidation setText:@"Error..."];
                NSLog(@"AVPlayerStatusFailed");
            }
                break;
        }
    }
    

    this works for me… I hope it help for you.

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

Sidebar

Related Questions

I am using AVPlayer to play an audio stream, and it's possible to keep
I'm using AVPlayer to stream audio content delivered in two quality formats. The problem
I'm successfully using AVPlayer to stream audio from a server and what I want
I am using AVPlayer to play a live stream from the Internet using the
I'm building an app which plays an audio stream (from a webradio). I'm using
I'm using AVPlayer to play live audio streamed from the Internet, but when it's
OK. AvPlayer is working great with streaming audio. In my app I have UISlider
I am trying to play a MediaItem using AVPlayer and later trying to get
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

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.