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
28
votes
3 answers

AVAudioPlayer stop a sound and play it from the beginning

I used the AVAudioPlayer to play a 10 sec wav file and it works fine. Now I what to stop the wav at the 4th sec and then play it again from the very 1st sec. Here is the code I tried: NSString *ahhhPath = [[NSBundle mainBundle]…
supersurabbit
  • 441
  • 1
  • 8
  • 14
27
votes
4 answers

iPhone: AVAudioPlayer unsupported file type

My app downloads an mp3 from our server and plays it back to the user. The file is 64 kbps (which is well within the acceptable range for iPhone if I understand correctly). I have looked up how to do this on dozens of sites and they all suggest that…
mtmurdock
  • 12,756
  • 21
  • 65
  • 108
27
votes
5 answers

How Do I Get Audio Controls on Lock Screen/Control Center from AVAudioPlayer in Swift

New to iOS development, so here goes. I have an app that is playing audio - I'm using AVAudioPlayer to load single files by name in the app's assets. I don't want to query the user's library, only the files provided. Works great, but, I want the…
nbpeth
  • 2,967
  • 4
  • 24
  • 34
26
votes
3 answers

Extract meter levels from audio file

I need to extract audio meter levels from a file so I can render the levels before playing the audio. I know AVAudioPlayer can get this information while playing the audio file through func averagePower(forChannel channelNumber: Int) -> Float. But…
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
26
votes
5 answers

Get AVAudioPlayer to play multiple sounds at a time

I'm trying to get multiple sounds files to play on an AVAudioPlayer instance, however when one sound plays, the other stops. I can't get more than one sound to play at a time. Here is my code: import AVFoundation class GSAudio{ static var…
Kai
  • 537
  • 2
  • 6
  • 13
25
votes
2 answers

converting all the mp4 audio files in a folder to mp3 using ffmpeg

how can I convert all of the mp4 files in a given folder to mp3 using ffmpeg. Almost all of the links I have seen on google is all about converting mp4 video to mp3. I can do this via VLC player but I have got huge collection ~ 1000 mp4 audio files…
Raulp
  • 7,758
  • 20
  • 93
  • 155
24
votes
5 answers

AVAudioPlayer playing Sound with very low volume in iPhone 6 and 6+

I am playing a sound using AVAudioPlayer. The sound volume in iPods (iOS7 & iOS8 both) is good. But when I play same sound in iPhones the sound is playing with very low volume. Here is my code: var audioPlayer: AVAudioPlayer? var soundURL:NSURL? =…
Mohammad Zaid Pathan
  • 16,304
  • 7
  • 99
  • 130
24
votes
5 answers

iOS 7 SDK not abiding background audio

I have done a lot of research, both on Google and StackOverflow. All the answers I found do not work in iOS 7. I started writing fresh app in iOS 7 SDK with Xcode 5. All I'm trying to do is play audio in the app from a file stored in the app bundle…
codejunkie
  • 1,122
  • 3
  • 13
  • 29
23
votes
6 answers

AVAudioPlayer error loading file

I am trying to use the AVAudioPlayer to play a simple sound and I keep getting this error in the console: 2011-09-02 20:29:07.369 MusicLog[967:10103] Error loading…
Kyle Rosenbluth
  • 1,672
  • 4
  • 22
  • 38
23
votes
6 answers

AVAudioPlayer: How to Change the Playback Speed of Audio?

I want to control the playback speed of audio in AVAudioplayer. Is this possible? If so, how would you do it?
jecob
  • 245
  • 1
  • 3
  • 5
22
votes
1 answer

MPMoviePlayerController and AVAudioPlayer audio mixing glitch

I'm developing an interactive storybook type application for the iPhone and I've recently encountered a frustrating bug concerning audio mixing on the device. Firstly, I setup an audio session. I set the category to AVAudioSessionCategoryAmbient and…
22
votes
7 answers

How to handle error code -43 from NSOSStatusErrorDomain when initializing AVAudioPlayer Object?

I observed strange behavior while working with AVAudioPlayer Following is the code: AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@",fileName]] error: &error]; In this,…
Tanu
  • 303
  • 1
  • 2
  • 13
21
votes
3 answers

How to increase volume of sound recorded using AVAudioRecorder

I am using the link mentioned below to record audio through my iPhone app: How do I record audio on iPhone with AVAudioRecorder? When I try to play my recordings using AVAudioPlayer on my device, I have seen that the sound volume of my recordings is…
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
21
votes
2 answers

Xcode stops on prepareToPlay

Using AVAudioPlayer to add sound to a working application, it stops / hangs on prepareToPlay. Note it also stops / hangs on play. Hitting "Continue program execution" several times makes the application resume. This problem only occurs when…
zermat
  • 991
  • 9
  • 15
21
votes
5 answers

How to Play a sound using AVAudioPlayer when in Silent Mode in iPhone

I want to play a sound even in silent mode in iPhone. Can it be done by using AVAudioPlayer (Without using AVAudioSession) (For ios 3.0+) Thanks in advance.
Nima
  • 969
  • 3
  • 10
  • 14