I am implementing a sound effect that plays while a user is dragging a UISlider.
Here is the IBAction: called by the UISlider's Value Changed event
-(IBAction)playTone4; {
AudioServicesPlaySystemSound(soundID4);
}
I would like the sound to halt when the user is not dragging the slider but has not released it.
Is there a way to do that? There doesn't seem to be an AudioServicesStopSystemSound() function.
System sounds cannot be stopped.
See the iPhone Programming Guide: section Multimeda Support for more information.
To accomplish the desired effect, I would recommend using AVAudioPlayer or audioQueues. The Programming Guide I addressed covers everything you want to know about these techniques.
Related
Is there a way to determine whether VoiceOver is currently announcing and when it stops. I've tried UIAccessibilityVoiceOverStatusChanged but my understanding is that this is only if you switch VoiceOver on or off. Any help would be greatly appreciated. thanks.
We use otherAudioIsPlaying, the problem is some app's running in the background like some pedometer monitors etc. turn on the audio it seems and never release it so even though nothing is actually being spoken or played otherAudioIsPlaying always returns 1 until you remove the other application from the background. So now not only can you not play music but you have no idea that another application in the background will mess up this test. Apple really needs to put in an API to determine if Voice Over is currently speaking or not.
These are all the Accessibility booleans that I found in the documentation:
UIAccessibilityPostNotification
UIAccessibilityIsVoiceOverRunning
UIAccessibilityIsMonoAudioEnabled
UIAccessibilityIsClosedCaptioningEnabled
UIAccessibilityRegisterGestureConflictWithZoom
I don't think that there are any booleans to do what you are talking about.
You could use the audio session's "OtherAudioIsPlaying" property to check if another system process is using the audio hardware at the moment. It should be "true" if VoiceOver is speaking and "false" if not.
Actually this might not work properly if the user is playing music in the background. But most users running VoiceOver will usually not have any other audio enabled permanently, since it makes it harder to understand what VoiceOver is saying.
Here is an example for usage:
UInt32 otherAudioIsPlaying;
UInt32 propertySize = sizeof(otherAudioIsPlaying);
AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying,&propertySize, &otherAudioIsPlaying);
if(otherAudioIsPlaying) {
// other application is generating sound output (including VoiceOver)
// but might also be any other app (like iPod App)
}
I have a UIPickerView in my app in which the 'tick' sound when moving from one index to the next is not played. I swear it used to play the sound, but recently it has not played.
I am using custom labels for each item in the picker, and I tried commenting that out and the sound still does not play.
I have searched around and saw there is a method [pickerView setSoundsEnabled:YES], but it is a private API, so I cannot use that.
Most threads I have found are people trying to stop the sound from playing, shouldn't it be playing the sound by default?
Any help appreciated, thanks.
I believe this sound is set/unset via the system-level preferences panel, Settings->Sounds->Keyboard Clicks->On, and cannot be set at the API level (at least, not officially).
The issue ended up being with using the FMOD library. I filed a bug report, it was when using the PLAY_AND_RECORD filter.
Can somebody tell me how to scrub the AQPlayer ( used in Apple's SpeakHere example ) using a UISlider like the iPod does?
I know how to handle the slider part, but once I have my value from the slider, what do I need to set/change/update in AQPlayer, or the AudioQueue, so that the player moves to that part of the Queue and continues playing from that point?
Is there any easy way to do this with a percentage of the playing time or do I have to make some calculations with the packets??
Thanks for any input.
Al
For anyone who also needs to seek/scrubb in an audio file, I found a solution to my question at the following link: Audio Queues
Have a look at the function
-(void)seek:(UInt64)packetOffset;
It worked perfectly after some initial fine tuning.
I want to play videos. I am using MPMoviePlayer, but I don't want to use the controls provided by MPMoviePlayer. So I am trying to create my own custom controls. All the functionality like play, pause, fullscreen, forward, backward are done. The only problem is with the scrubber. I am having one UISlider but I don't know how exactly work with this. How to track the currently playing video time? How to play video from where I will slide the thumb of slider?
If anyone knows this kindly help me in this.
Thanks in advance.
I was having a similar problem. I figured out how to create custom movie controls and put it up on github. Let me know if that helps. Feel free to ask me any questions if you want details.
First, we should note that all of this is possible in iOS 3.2+, if you are OK not to support iOS 3.1.x.
In iOS 3.2+, MPMoviePlayerController implements the MPMediaPlayback protocol, meaning that it responds to play, stop, etc., all the controls you would expect -- sounds like you already have some of this working. Please see the reference for the MPMediaPlayback protocol.
To get the MPMoviePlayerController to stop showing its own controls, do this on initialization:
yourPlayer.controlStyle = MPMovieControlStyleNone;
Finally, to get the scrubber to work, you need to set the UISlider valueChanged: callback to something, and update the value of currentPlaybackTime property. If you want to seek 10 seconds in:
yourPlayer.currentPlaybackTime = 10;
I'm obviously not trying to play full spectrum audio, but is there some way to customize the iPhone/iTouch system alert sounds to play a little melody on the piezo speaker? The functionality is clearly present, so I guess the question is has Apple made it available for developer use...
Thanks,
-S
There are quite a few predefined sounds you can use in the 0-2000 range. For example, the keyboard click can be called like such:
AudioServicesPlayAlertSound(1104);
There is also a way to play a custom melody on the first-generation iPod touch, but it's not pretty.
It isn't. Sorry.
Only thing you can do from an application is this (you can use any SoundID for this, really):
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
Discussion
Depending on the particular iPhone OS device, this function plays a short sound and may invoke vibration. Calling this function does the following on various iPhone OS devices:
iPhone—plays the specified sound and, if the user has configured the Settings application for vibration on ring, invokes vibration.
iPod touch, original—plays a short alert melody.
iPod touch, 2nd generation—plays the specified sound.