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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:07:41+00:00 2026-05-28T13:07:41+00:00

I have a view that pushes another view with navigation controller. In this second

  • 0

I have a view that pushes another view with navigation controller. In this second view I play an audio which I want to continue playing even when the user gets back to the first view, popping the second view away, just like in iPod app. How can I do that?

  • 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-28T13:07:42+00:00Added an answer on May 28, 2026 at 1:07 pm

    You should abstract your audio playing from your view controller, since it’s not really related functionality (and plus it’ll let you do what you want). I would suggest creating a singleton object who’s functionality is to play a specified song, pause/stop it, and retrieve statuses from it (such as isPlaying, etc). I’m not going to go deeply into what a singleton is/how to make one, since other stack overflow posts and a quick google search will yield results, however the basic premise is that you create a class and add this method to it:

    + (id)sharedInstance
    {
        static dispatch_once_t dispatchOncePredicate = 0;
        __strong static id _sharedObject = nil;
        dispatch_once(&dispatchOncePredicate, ^{
            _sharedObject = [[self alloc] init];
        });
        return _sharedObject;
    }
    

    Then you can create a method like so:

    + (void)playSongWithFile:(NSString *)fileName
    {
        // retrieve the file and play it
    }
    

    And from any class in which you #import your singleton object, you can call:

    [[MySingleton sharedInstance] playSongWithFile:@"awesomesong.mp3"];
    

    A singleton object is an object that can only be instantiated once and “lives on” for the duration of your app’s execution, so it’ll continue doing what you tell it regardless of what’s going on with your view controllers.

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

Sidebar

Related Questions

I have a navigation root view controller, which I am pushing to another view
I have a UIButton that pushes to another view controller using the following code.
I have a detail view that includes three UIButtons, each of which pushes a
I want to have a TabBar controller inside a navigation controller. So that when
I have a detail view that includes three UIButtons, each of which pushes a
I have a view controller that i'm trying to push onto the navigation stack.
I have a Navigation controller in my app that pushes my homeview on load.
I have a view (viewB) that is pushed in using the navigation controller from
I know that the presence of the more view controller (navigation bar) pushes down
I have a view that I want to add some custom drawing to. I

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.