I'm having trouble with playing audio stream using MPMoviePlayerController in the background. On the foreground it's playing the audio just fine, but when the application goes to the background, sound disappears and the time keeps going. I have initialized the AVAudioSession with AVAudioSessionCategoryPlayback and have put the required background modes to audio in info.plist file. Also I have set player.useApplicationAudioSession = YES;. What could be the possible problem here? Thanks in advance :)
This ios background link indicates that the useApplicationAudioSession property value should be set to NO for iOS 3.2 and newer. (I have an app that does this and it works fine in background mode.
Related
When playing a movie through a UIWebView, and then outputting to AppleTV via Airplay, turning off iPhone screen stops playback. Why?
Anyone know how to solve this so AirPlay continues when the screen is off with my app?
Doing these two things solved it for me:
Airplay of audio using AVPlayer does not work in the background (Put the key "audio" as the key in the XML of the property list)
UIWebView: HTML5 audio pauses in iOS 6 when app enters background
Looks like it works for video too!
I am having trouble playing audio inside a MPMoviePlayerViewController in the background. I can point it to mp3's just fine and listen to the audio, but when I go into the background, I don't hear audio anymore.
I set the plist entry to keep playing audio and set the audio session toAVAudioSessionCategoryPlayback. When I hit the home button, wait a few seconds, and go back to the app, the audio advanced as if it had kept playing, I just can't hear a thing when the app is in the background.
Any idea what causes this?
Thanks!
I just tested in the simulator, and it fails there. It does work fine on the device though. Must be a bug in the simulator.
I'm making iphone program. The main function is playing video files, and recording sound.
OS 3.1.3 version is fine. But iPhone 4.0 makes problem!!
When I executed playing video (MPMoviePlayerController) and continuously recording sound (AVAudioRecorder), AVAudioRecorder doesn't work....
No recording..! ;o;
Somebody help!!
Check the useApplicationAudioSession property on MPMoviePlayerController. In iOS 3.1.x, the movie player was always getting its own system provided audio session. In iOS 4.0, it can now share the application session, and that's the default value as well. Try switching that property to NO before starting to play your movie.
When my app is backgrounded, the audioplayer continues to play, but i cant hear any sound. When i open my app again, it plays from the point where it would have been had the app not been backgrounded at all. This shows that the app is playing in the background though it is not audible. Why could this be happening?
I have set the audio key in the info.plist for the UIBackgroundModes array. Also my audioplayer is set to the "AVAudioSessionCategoryPlayback" category with an override to allow for audio mixing. So what am i doing wrong that im unable to hear the audio even though it is playing in the background?
Could this be an issue with the simulator alone as i have not been able to test this on a device with iOS4 so iv only been testing it on the simulator.
It's an issue with the simulator most likely. I implemented what you stated and it works just fine on the device: Entering background on iOS4 to play audio
I've been trying to make the iPhone Vibrate using this code:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
But is not working, could it be because I am playing sound at the same time as calling this?
If this helps anyone, I discovered that the vibrate command won't work while AVAudioRecorder is recording. Getting round this is very simple. You just have to stop your recorder first and resume it afterwards:
[recorder stop];
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
[recorder record];
This even works if you want to record sound and vibrate in the background using UIBackgroundModes.
That should work fine. Has vibration been turned off on the device?
I'm using that code successfully on iPhone 4. It's not clear from the documentation of System Sound, but that code works only if the vibration is enabled in Settings.
Of course note that there are two different settings for the vibration: silent mode and normal mode. Toggling the Ring/Silent switch to Silent is not sufficient to enable vibration.
I guess you've already tried enabling the vibration in your device Settings, but worth highlighting this anyway.
On all iPhones that I've tested on (original, 3GS, and 4), it should vibrate. On the iPod touch 1st generation, it'll play a beep through the built-in speaker. On the iPod touch 2nd generation, it won't do anything. On the iPad, it won't do anything either. Those are all the devices I've tested on.