I am using the following code to keep playing audio when iPhone/iPod goes sleep or locked.
mv = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://myurl/myMusic.mp3"]];
mv.movieSourceType = MPMovieSourceTypeUnknown;
[self.view addSubview:mv.view];
[mv play];
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory); AudioSessionSetActive(true);
By using this code my device is not going into sleep mode but what i want is, device should go in sleep mode but audio should not stop playing.
I have added Required background modes
and App plays audio
in my info.plist
file.
Please suggest me where am I wrong? Why the device is not going into sleep mode/locked?