Questions tagged [avaudioplayer]

Apple’s AVFoundation framework includes AVAudioPlayer, an easy, feature rich, Objective-C based API for playing audio files.

An instance of the AVAudioPlayer class, called an audio player, provides playback of audio data from a file or memory.

Apple recommends that you use this class for audio playback unless you are playing audio captured from a network stream or require very low I/O latency. For an overview of audio technologies, see Audio & Video Starting Point and “Using Audio” in Multimedia Programming Guide.

Using an audio player you can:

  • Play sounds of any duration
  • Play sounds from files or memory buffers
  • Loop sounds
  • Play multiple sounds simultaneously, one sound per audio player, with precise synchronization
  • Control relative playback level, stereo positioning, and playback rate for each sound you are playing
  • Seek to a particular point in a sound file, which supports such application features as fast forward and rewind
  • Obtain data you can use for playback-level metering

Source: ADC - AVAudioPlayer Class Reference

2788 questions
1
vote
2 answers

Memory Leak - NSString & NSURL

@property ( nonatomic, strong ) NSURL * urlPath; self.urlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"bark" ofType:@"caf"]]; Running ARC, deployment target 4.3. Instruments gives a leak on the self.urlPath = line. The…
iOSProgrammingIsFun
  • 1,418
  • 1
  • 15
  • 32
1
vote
3 answers

How to set a delegate to a class method

Can the AVAudioPlayer delegate be set to a class member audioPlayerDidFinishPlaying? I want to use a class method to play a sound file, but can't figure out how to set setDelegate: to the audioPlayerDidFinishPlaying class method. I have a small…
Doug Null
  • 7,989
  • 15
  • 69
  • 148
1
vote
1 answer

AVAudioPlayer crashing on ipad simulator but working fine on iPhone simulator

This is very odd, my app works fine on the iPhone (simulator and device) but crashes on the ipad simulator. The error always points to the prepareToPlay method. When i took that method off it then points to the play method. The debug area does not…
linobcr
  • 21
  • 4
1
vote
0 answers

AVAudioplayer continue to play sound while UIWebView is playing embedded video

I have this issue with mu AVAudioplayer continue to play sound when I play an embedded video in uiwebview inside my app. If I play the video from safari, it works fine, the audio from my app will fade out then stop to begin play the video from…
Kyle Mai
  • 133
  • 2
  • 14
1
vote
1 answer

CocosDenshion - CDAudioManager's load method fails

I am trying to play a background music for a scene of a game I am developing using Cocos2d 2.0 but the execution stops at in CDAudioManager.m: -(void) load:(NSString*) filePath { ........ ......... [[audioSourcePlayer prepareToPlay];…
mim
  • 199
  • 1
  • 3
  • 10
1
vote
1 answer

Cant play wav audio file on IPhone or Mac

Im developing an IPhone app and am including a sound file to play. I want to convert it to a CAF file. I know about the afconvert tool, but my problem is any of the MAC audio tools like afplay just return an error: Error: AudioFileOpen failed…
NYTom
  • 524
  • 2
  • 14
1
vote
0 answers

Play audio if headset is plugged-in

Possible Duplicate: How can I find out if an external headset is connected to an iPhone? I'm developing an audio-player application and in one of modes(playing mode) i want to detect the status of headset, if the jack is plugged in it should…
ilhan çetin
  • 383
  • 5
  • 19
1
vote
1 answer

iDevice native headphones button function change

I have and app with AVAudioPlayer. And I want to change headphone button functions from "volume up / volume down" to "play-pause / forward". Is it possible? Looking for any help
iWheelBuy
  • 5,470
  • 2
  • 37
  • 71
1
vote
1 answer

Audio playing in background not working in iOS Simulator

I've seen lots of questions about playing audio in the background. These questions often ask why the audio plays in the background of the simulator, yet the device simply wouldn't. In my case, it's reversed. When I tested my sample app in my iPad,…
Anna Fortuna
  • 1,071
  • 2
  • 17
  • 33
1
vote
1 answer

AVAudioPlayer only plays a custom audio file for one second

In my application I am using an AVAudioRecorder object to allow the user to record a sound file, and when the user is done recording they can play the sound via the AVAudioPlayer. The issue I'm having is when the user tries to play the audio file it…
miken.mkndev
  • 1,821
  • 3
  • 25
  • 39
1
vote
1 answer

audioPlayer sound played on IPhone different than IPAD (Iphone is low volume and has to be held to ear)

I am playing a sound file in an APP and on the iPhone plays with volume like it is a phone call (you have to hold the phone to your ear). When played on the iPad it plays like you would expect, sounds like a music file being played. Does anyone know…
JohnMH
  • 21
  • 2
1
vote
1 answer

play a .m4a file from iPod Music Library using avaudioplayer

Does anyone know how to play a selected .m4a file from the iPhone's iPod music library using a AVAudioPlayer? Is it possible to either export or copy the file to local Documents directory of the iPhone? Can anyone share any sample code to…
Bryan C
  • 1,594
  • 4
  • 16
  • 30
1
vote
1 answer

ios AVAudioPlayer plays sound with echo

I have two AVAudioPlayer to determine what sound has finished to do something after that. the first sound plays just fine but the second sound (twoPlayer) plays the sound with echo. any of you knows why or how this happend? I have this on my .h…
Juan
  • 627
  • 2
  • 9
  • 27
1
vote
1 answer

Objective C: Audio works on simulator but not in device

There's could be a in my apps cause when I tried to build it in iPhone device, i cannot hear a sound and i couldn't also use the volume button of the device.. while when i build it in simulator it works perfectly.. I tried using the code below but…
1
vote
0 answers

how to do audio fade out

I want to fadeout audio after a perticular time for example:- my audio duration is 4 sec and fade out time is 2 sec then after 2 sec i want to fadeout(decrease the volume of player) the audio for that i have written this function but its not…
deve1
  • 195
  • 1
  • 3
  • 14
1 2 3
99
100