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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:14:30+00:00 2026-06-03T11:14:30+00:00

I setup AVPlayerLayer with : audioPlayer = [[AVPlayer alloc]initWithURL:[NSURL fileURLWithPath:fileName]]; avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:audioPlayer];

  • 0

I setup AVPlayerLayer with :

        audioPlayer = [[AVPlayer alloc]initWithURL:[NSURL fileURLWithPath:fileName]];
        avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:audioPlayer];
        [avPlayerLayer setFrame:self.view.bounds];
        [[self.view layer] addSublayer:avPlayerLayer];
        [audioPlayer play];

In the AppDelegete i add :

[[AVAudioSession sharedInstance] setDelegate:self];    
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];

Now in UIViewController Class i add:

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];
}

- (BOOL)canBecomeFirstResponder {
    return YES;
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
    switch (event.subtype) {
        case UIEventSubtypeRemoteControlTogglePlayPause:
            if (audioPlayer.rate == 0.0) {
                [avPlayerLayer.player play];
            } else {
                [avPlayerLayer.player pause];
            }
            NSLog(@"4");
            break;
        case UIEventSubtypeRemoteControlPlay:
            [avPlayerLayer.player play];
            break;
        case UIEventSubtypeRemoteControlPause:
            [avPlayerLayer.player pause];
            NSLog(@"3");
            break;
        case UIEventSubtypeRemoteControlNextTrack:
            [self didPressNextSong:nil];
            NSLog(@"2");
            break;
        case UIEventSubtypeRemoteControlPreviousTrack:
            [self didPressLastSong:nil];
            NSLog(@"1");
            break;
        default:
            break;
    }
}

Now the problem is that when i move to background mode the song stop playing but when i press the play button in the remote control(the menu that popup when i press double click on the home button) the song keep playing from where it stoped.

Any idea why i have this issue?

  • 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-03T11:14:32+00:00Added an answer on June 3, 2026 at 11:14 am

    See this solution:

    How do I get my AVPlayer to play while app is in background?

    The key is in the UIBackgroundModes in the info plist.

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

Sidebar

Related Questions

Setup: Tab Bar App First View is a ScrollView which has an ImageView as
Setup: I have parent view A. It has a child view B. B is
Setup: I have a COM DLL that calls a method inside a managed C#
Setup : I have a Struts web application where I use displaytag elements to
Setup: I have a UITextView inside a UITableViewCell 's contentView . I want it
Setup: Contact database using 4 tables Contacts Cities States Zips Structure: CREATE TABLE `contacts`
setup and deployment project template is missing in my installtion is there any alternate
Setup : Using PowerBuilder 6.5. I have a composite report (with a report header)
Setup: Multiple sites on Django on the same set of servers, being served by
Setup: mysql> create table t(a integer unsigned,b integer unsigned); mysql> insert into t(a,b) values

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.