Popular questions for this item

how to play background

if you are downloading v1.1, it already supported if it is the v1.0 version to the following things

1. in lyrcsPlayer-Info.plist, add one row for “Required background modes”, and set the Item0 to be “App plays audio”

2. add the following code at the end of ViewController.m


- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    //Once the view has loaded then we can register to begin recieving controls and we can become the first responder
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];

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

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    //End recieving events
    [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
    [self resignFirstResponder];
}

- (BOOL)canBecomeFirstResponder {
    return YES;
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
    //if it is a remote control event handle it correctly
    if (event.type == UIEventTypeRemoteControl) {
        if (event.subtype == UIEventSubtypeRemoteControlPlay) {
            [self.player play];
        } else if (event.subtype == UIEventSubtypeRemoteControlPause) {
            [self.player pause];
        } else if (event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {
            if (self.player.isPlaying) {
                [self.player pause];
            } else {
                [self.player play];
            }
        } else if (event.subtype == UIEventSubtypeRemoteControlNextTrack) {
            [self playNext];
        } else if (event.subtype == UIEventSubtypeRemoteControlPreviousTrack) {
            [self playPrev];
        }
    }
}

by
by
by
by
by
by