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
13
votes
2 answers

AVAudioRecorder currentTime giving bad values

I have a setup as follows, testing on an iPhone 5s with iOS 10.3, both in and out of debug. An AVAudioRecorder fires record(forDuration: 5.0) A CADisplayLink watches the levels of the recorder (the recorder is meteringEnabled), synchronizing an…
13
votes
1 answer

Swift: how to set the iphone volume programmatically

I am trying to create an alarm app and I have noticed that apps like Sleep Cycle will set your volume to max right before the alarm goes off, even if you had the volume at very low. I have tried using AVAudioPlayer and all I have seen with…
Charles
  • 393
  • 1
  • 3
  • 15
13
votes
1 answer

Using Apple's new AudioEngine to change Pitch of AudioPlayer sound

I am currently trying to get Apple's new audio engine working with my current audio setup. Specifically, I am trying to change the pitch with Audio Engine, which apparently is possible according to this post. I have also looked into other pitch…
jake
  • 161
  • 1
  • 5
13
votes
5 answers

How to play the iPod Library file in the AVPlayer

How can I get an ipod library music file into AVAudioPlayer?
user237708
13
votes
3 answers

How to enable audio scrubber in iOS Lock Screen control panel?

I have the following dictionary for MPNowPlayingInfoCenter @{MPMediaItemPropertyAlbumTitle: @"First Title", MPMediaItemPropertyArtwork: [[MPMediaItemArtwork alloc] initWithImage:[UIImage…
Ashish Awaghad
  • 2,822
  • 3
  • 24
  • 33
12
votes
2 answers

AVAudioPlayer stops playing on screen lock even though the category is AVAudioSessionCategoryPlayback

My app uses AVAudioPlayer to play through audio playlists. I haven't changed the code between iOS4.3 and iOS5. However, the audio on iOS5 pauses on a screen lock even though I've set the category to be AVAudioSessionCategoryPlayback. I've tested the…
Sid
  • 9,508
  • 5
  • 39
  • 60
12
votes
3 answers

AVAudioPlayer stops playing immediately with ARC

I am trying to play an MP3 via AVAudioPlayer which I thought to be fairly simple. Unfortunately, it's not quite working. Here is all I did: For the sake of testing, I created a new iOS application (Single View) in Xcode. I added the AVFoundation…
12
votes
3 answers

how to play .ogg audio file using AVAudioPlayer in Swift 3?

i'm trying to play audio file with AVAudioPlayer with this code: let urlString = "http://192.168.1.19:8080/download/2" let url = URL(string: urlString)! print("the url = \(url)") do { let data = try Data.init(contentsOf:…
calvin sugianto
  • 610
  • 7
  • 27
12
votes
3 answers

AVAudioPlayer crackles and pops

I have a Simon-like memory game where a sequence of tones is played and the user attempts to repeat the tones. The problem is that I get a horrible crackly, popping sound from time to time. It could be after just a few notes or as many as twenty.…
squarehippo10
  • 1,855
  • 1
  • 15
  • 45
12
votes
1 answer

Stop setting up several AVAudioPlayers with playAtTime() in a for loop

When selecting a row the following code sets up a set of AVAudioPlayers to playback at a certain date (in this case, 50 players playing in the interval of 1 second). Since I want the whole process to restart when touching again I need to break the…
nontomatic
  • 2,003
  • 2
  • 24
  • 38
12
votes
7 answers

Audio playing while app in background iOS

I have an app mostly based around Core Bluetooth. When something specific happens, the app is woken up using Core Bluetooth background modes and it fires off an alarm, however I can't get the alarm working when the app is not in the foreground. I…
Darren
  • 10,182
  • 20
  • 95
  • 162
12
votes
4 answers

Lower iPod volume to play app sound (like the native SMS app)

I've made an iPhone app to be used while exercising. It plays a bell tone to indicate that you (the user) should switch from one step of your exercise routine to the next. I've designed the app so that you can listen to music on the iPod while…
11
votes
3 answers

iOS - AVAudioPlayer doesn't continue to next song while in background

So I have an app that plays a bunch of songs while the user can flip through a comic book. I use AVAudioPlayer and I have it set up to play the songs in a set order. So when one song finishes, the next one will play. This works flawlessly when…
kernelpanic
  • 530
  • 2
  • 8
  • 26
11
votes
3 answers

Record and play audio simultaneously in iOS

I am trying to play the recorded content simultaneously while recording. Currently I am using AVAudioRecorder for recording and AVAudioPlayer for playing. When I was trying to play the content simultaneously nothing is playing. Please find the…
Srini S
  • 111
  • 2
  • 4
11
votes
3 answers

Get input of switch control via headphone jack on iOS

As a little holiday project I want to control an app via an accessibility switch which is connected via 3,5mm headphone jack to the iOS device. This is the switch and the plug: My problem is that I don't have any clue what kind of signal is fired…
arnoapp
  • 2,416
  • 4
  • 38
  • 70