Questions tagged [avaudioplayer]

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

avaudioplayer
Filter by
Sorted by
Tagged with
108 votes
6 answers
12k views

AVAudioPlayer throws breakpoint in debug mode

Every time I load the app it stops as if I had set a breakpoint on this line: self.audioPlayer = [[[AVAudioPlayer alloc] initWithData:[dataPersister loadData:self.fileName] ...
ThomasCle's user avatar
  • 6,791
73 votes
8 answers
105k views

Playing a sound with AVAudioPlayer

I'm trying to play a sound with AVAudioPlayer but it won't work. Edit 1: Still doesn't work. Edit 2: This code works. My device was in silent mode. import UIKit import AVFoundation class ...
user3722523's user avatar
  • 1,750
66 votes
8 answers
22k views

Are headphones plugged in? iOS7

Developing an app for an iPhone with audio files that need to be listened too through headphones. How do I check if headphones aren't plugged in so I can tell the user to plug in headphones. I have ...
4GetFullOf's user avatar
  • 1,738
64 votes
8 answers
68k views

Play sound on iPhone even in silent mode [duplicate]

I want to make an application which creates sound, music, or system sound when an iPhone is in silent mode. Is it possible to play any type of sound whether music or system tones when it is silent ...
Pankaj Kainthla's user avatar
51 votes
12 answers
34k views

AVAudioPlayer fade volume out

I have an AVAudioPlayer playing some audio (duh!) The audio is initiated when the user presses a button. When they release it I want the audio to fade out. I am using Interface builder...so I am ...
user avatar
47 votes
8 answers
18k views

How do I start playing audio when in silent mode & locked in iOS 6?

End-user process Open app Switch on 'Silent Mode'. Press 'Lock-button' App can still START playing a sound after hours have passed, not playing any audio in the interim. Apps that do this A lot of ...
Andres Canella's user avatar
44 votes
12 answers
99k views

How to play mp3 audio from URL in iOS Swift?

I am getting mp3 url as a response of an API call. I want to play that audio, so how can I do that? here is my response { content = "En este primer programa se tratar\U00e1n asuntos tan ...
Govind's user avatar
  • 451
43 votes
9 answers
24k views

Slow start for AVAudioPlayer the first time a sound is played

I'm trying to eliminate startup lag when playing a (very short -- less than 2 seconds) audio file via AVAudioPlayer on the iPhone. First, the code: NSString *audioFile = [NSString stringWithFormat:@"...
John Biesnecker's user avatar
41 votes
12 answers
41k views

Play music in the background using AVAudioplayer

I want to play music even if the app goes in background. I checked all stackoverflow links but none of them worked. Please help need to do it today. I had used following code:- NSString *...
leena's user avatar
  • 699
35 votes
11 answers
34k views

How to get AVAudioPlayer output to the speaker

I'm recording audio with AVAudioRecorder as seen in How do I record audio on iPhone with AVAudioRecorder? I then use AVAudioPlayer to play back the recording. However the sound is coming out of the ...
dizy's user avatar
  • 7,981
34 votes
7 answers
41k views

UISlider to control AVAudioPlayer

I'm trying to implement a little function in my app. I am currently playing sounds as AVAudioPlayers and that works fine. What I would like to add is to control the sound's position (currentTime) with ...
David Pollak's user avatar
34 votes
7 answers
34k views

Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?

I've tried using these methods in an attempt to detect that the Ring/Silent switch is active or not: How to programmatically sense the iPhone mute switch? AVAudioSession category not working as ...
taber's user avatar
  • 3,186
30 votes
3 answers
9k views

AVAudioPlayer produces lag despite prepareToPlay() in Swift

Playing a very short sound (~0.5s) produces a hiccup (like a lag) in my SpriteKit iOS game programmed in Swift. In other questions, I read that I should prepareToPlay() the sound, which I did. I ...
Timme's user avatar
  • 425
29 votes
3 answers
55k views

Supported Audio file formats in iPhone [closed]

What are the supported audio files formats in iPhone? If I want to play a 2 hour audio files , what is the best audio file format I should have in my App? Thanks
Biranchi's user avatar
  • 16.2k
28 votes
3 answers
11k views

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 *...
supersurabbit's user avatar
28 votes
5 answers
10k views

What do you use to play sound in iPhone games?

I have a performance-intensive iPhone game I would like to add sounds to. There seem to be about three main choices: (1) AVAudioPlayer, (2) Audio Queues and (3) OpenAL. I’d hate to write pages of low-...
zoul's user avatar
  • 103k
27 votes
5 answers
26k views

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 ...
nbpeth's user avatar
  • 3,078
27 votes
4 answers
25k views

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 ...
mtmurdock's user avatar
  • 12.9k
26 votes
5 answers
22k views

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: ...
Kai's user avatar
  • 537
26 votes
3 answers
9k views

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 ...
Peter Warbo's user avatar
  • 11.3k
25 votes
5 answers
23k views

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: ...
Zaid Pathan's user avatar
  • 16.5k
25 votes
2 answers
25k views

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

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 ...
Raulp's user avatar
  • 7,968
24 votes
5 answers
13k views

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 ...
codejunkie's user avatar
  • 1,122
23 votes
6 answers
21k views

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's user avatar
  • 245
23 votes
6 answers
11k views

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 /System/Library/Extensions/AppleHDA....
Kyle Rosenbluth's user avatar
22 votes
7 answers
20k views

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 ...
Tanu's user avatar
  • 303
22 votes
1 answer
2k views

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 ...
jdmunro's user avatar
  • 581
21 votes
2 answers
4k views

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 ...
zermat's user avatar
  • 991
21 votes
6 answers
15k views

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's user avatar
  • 979
21 votes
3 answers
19k views

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 ...
Parth Bhatt's user avatar
  • 19.5k
20 votes
4 answers
12k views

iPhone AVAudioPlayer stopping background music

So I've just noticed that on my iPod Touch, when my app triggers a short wav file to play using AVAudioPlayer, the music gets paused. Is this normal? I can't find any reference to this, and it seems ...
Kenny Winker's user avatar
20 votes
4 answers
10k views

AVAudioRecorder & AVAudioPlayer with iOS 7 not working properly

i'm having some issue with AVFoundation framework. I wrote a demo app to record audio, play it, and calculate decibels, with iOS 6. It both worked with iOS simulator built-in xcode 4.6.3 and my iPhone ...
ace_ventura's user avatar
19 votes
4 answers
16k views

MP3 playing using AVAudioPlayer not working on device

I am testing my app on my 3GS iPhone with iOS 4.2 I am using the following code which plays a sound in my IBAction. It works perfectly in the simulator (both iPad and iPhone) - I hear the sound. ...
Matt Facer's user avatar
  • 3,103
19 votes
4 answers
4k views

iOS 13.1 Crash in AVAudio Player

My App is crashing on iOS 13.1 when i trace a issue then found App is crashing because of AVAudioPlayer. Below Is My Player Setup. if let wrongURL = Bundle.main.url(forResource: "wrongAudio", ...
Rakesh Patel's user avatar
  • 1,693
19 votes
2 answers
16k views

Do an action when a sound has finished playing in AVAudioPlayer?

I am using the AVAudioPlayer framework, and I have several sounds that play one at a time. When a sound is finished playing, I want the application to do something. I tried to use ...
Evelyn's user avatar
  • 2,628
19 votes
5 answers
10k views

How to customize MPVolumeView?

I have tried many methods to implement a regular UISlider and control the device volume, but it's all Native-C functions which results in many untraceable bugs. I tried the MPVolumeView it works ...
mohdajami's user avatar
  • 9,644
19 votes
4 answers
9k views

How to do screen mirroring using AirPlay from the application (not from control centre) in iOS?

I am using MPVolumeView to show AirPlay button. I need to show a custom wallpaper to Apple TV through mirroring with audio. Audio is playing properly on Apple TV but wallpaper image is not showing. I ...
Mukesh2421's user avatar
18 votes
3 answers
11k views

AVAudioPlayer resetting currently playing sound and playing it from beginning

I'm having an issue using AVAudioPlayer where I want to reset a player if it's currently playing and have it play again. I try the following with no luck: The sound plays once but then the second ...
Dougnukem's user avatar
  • 14.8k
18 votes
2 answers
13k views

Entering background on iOS4 to play audio

The documentation is rather poorly written when talking about playing audio in the background. It gives the impression that all you have to do to continue playing the audio that you are currently ...
iwasrobbed's user avatar
  • 46.6k
18 votes
7 answers
5k views

AVAudioPlayer working in Simulator, but not on device

My mp3 playing code is: NSError *error; soundObject = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:audioPathString] error:&error]; if (soundObject == nil) NSLog(@"%@", [...
cannyboy's user avatar
  • 24.3k
17 votes
3 answers
19k views

AVAudioPlayer with external URL to *.m4p

My Problem is the following. I got this code and i guess a corrupt NSURL since the AVAudioPlayer is nil after initializing: NSString *dummyURLString = @"http://a825.phobos.apple.com/us/r2000/005/...
tommy's user avatar
  • 173
17 votes
7 answers
24k views

IOS 8 Swift AVAudioPlayer play remote audio (wowza server)

I am not an IOS programmer but I need a simple app to play an audio stream from a wowza server. Here is my code, I get no errors but also no audio. Any guidances or help? import UIKit import ...
David Turton's user avatar
17 votes
2 answers
8k views

Why do the Lock Screen audio controls disappear when I pause AVAudioPlayer?

I'm using an instance of AVAudioPlayer to play an audio file. The app is configured to play audio in the background and an appropriate audio session is set. I am also successfully receiving remote ...
maml's user avatar
  • 594
17 votes
3 answers
7k views

How to connect the audio to bluetooth when playing using AVPlayer

I am playing the audio from an url using AVPlayer, but when the iPhone is connected to a Bluetooth device it is not playing via Bluetooth, how to play via Bluetooth if it is connected, i see some ...
Sudheer Kumar Palchuri's user avatar
17 votes
2 answers
4k views

AVFAudio playback crash on iOS 10

I've got an app with a very basic audio component: a looping set of background songs played with an AVAudioPlayer (song filenames stored as an array). Everything has been working fine for months, but ...
Nerrolken's user avatar
  • 1,985
17 votes
1 answer
3k views

Record Video and play audio at same time ios

I want to record video and play audio simultaneously. when start recording video, preloaded audio start play and when stop video recording, audio also stops playing. I tried to record Video by using ...
Bhargav B. Bajani's user avatar
17 votes
1 answer
8k views

AVFoundation: Video to OpenGL texture working - How to play and sync audio?

I've managed to load a video-track of a movie frame by frame into an OpenGL texture with AVFoundation. I followed the steps described in the answer here: iOS4: how do I use video file as an OpenGL ...
j00hi's user avatar
  • 5,670
16 votes
4 answers
29k views

Swift 3 sound play

Ok I have looked into this and have tried many different ways to play a sound when a button is clicked. How would I play a sound when a button is clicked in swift 3? I have my sound in a folder named ...
shane's user avatar
  • 342
16 votes
8 answers
12k views

Play background music in app?

I want the user to be able to open the app and have music start playing. I want the user to be able to go any view controller and return back to the initial one without the music stopping. I want it ...
user avatar
16 votes
2 answers
12k views

Are there any other iOS system sounds available other than 'tock'?

I have implemented an alternative keyboard on my first iPhone app. I would like to play a sound when a button is pressed. The default click sound when the standard keyboard is pressed would be fine, ...
Dale Dietrich's user avatar

1
2 3 4 5
57