Get iPhone to Vibrate - iphone

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.

Related

Playing a System sound in tvos [swift]

In iOS I can play a system sound with the following code:
// import this
import AVFoundation
// create a sound ID, in this case its the tweet sound.
let systemSoundID: SystemSoundID = 1016
// to play sound
AudioServicesPlaySystemSound (systemSoundID)
There is this link https://github.com/TUNER88/iOSSystemSoundsLibrary to a list of available system sounds in iOS
My question is are system sounds available in tvOS? and which ones are available.
SO I found the Answer. . .
The above code works fine on an actual Apple TV. It does not work in the simulator. (It plays no system sounds in the Simulator.) Must be a bug.
I'm using Xcode version 7.3 and the 9.3 tvOS Simulator.
The above link to a list of sound files seems to work. I've tried 5 different systems sounds that work.
If the sound doesn't play in the simulator but does play on a live Apple TV, it might be that you've disabled user interface sounds.
To enable, load the System Preferences, select Sounds, and then tick the Play user interface sound effects checkbox (and also increase the Alert volume)
When you play the system sound, it should play in the simulator now.

MPMoviePlayerController playback problem

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.

Why are the AudioServices used to vibrate an iphone?

Is the only way to vibrate an iphone using the AudioServices?
If so, why was it run through Audio to vibrate the device?
One usually associates vibrations synonymous with audio/alerts (System Alerts, Text Messages, receiving a call). As this is done through the Audio Services it makes sense to also be able to make the phone vibrate this way.
why was it run through Audio to vibrate the device
Just to point out, it's not vibrating the device using the soundwaves made by playing audio.

MPMoviePlayerViewController and background audio

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.

iOS4 and audio playback during backgrounding

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