avaudioplayer

AudioPlayer and lockscreen/control center control Swift [closed]

南笙酒味 提交于 2019-12-04 07:31:18
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I'm new on Swift. I write because I want to ask a question. Me and my friend we are developing an audio player, but we have a problem. The player also works in background and remote controls from the lockscreen and the control center work, but if music is interrupted by one of these two controls, the play/pause button of our player is not updated with the correct icon. My question is, how can I make

AudioServicesPlaySystemSound muted on simulator xCode 6 GM

ⅰ亾dé卋堺 提交于 2019-12-04 07:03:58
I run the following code on simulator and I don't get any sound: NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"pageflip" ofType:@"mp3"]; NSURL *soundUrl = [NSURL fileURLWithPath:soundPath]; AudioServicesCreateSystemSoundID((__bridge CFURLRef) soundUrl, &_soundEffect); AudioServicesPlaySystemSound(_soundEffect); The code has been successfully tested on xCode 5 and iOS 7. Libraries imported as required. I've logged the soundPath and it returns the correct location on the filesystem. Has anyone experienced a similar issue? This is an issue with the simulator. On a device it'll

AVAudioPlayer not playing m4a or mp3 filetype from a website

旧城冷巷雨未停 提交于 2019-12-04 06:47:58
问题 I am trying to locate a URL which is only pure .m4a sound with my application. I have the URL to the audio and theoretically download it. Then, with the downloaded fileURL to the sound, I try to play it with the AVAudioPlayer, yet it does not play any sound. Here is my code: In the URL retrieval function, I call: (urls defined as a URL(string: url) , url being the retrieve URL string) downloadSound(url: urls!) Here is my downloadSound() function: func downloadSound(url:URL){ var downloadTask

Game lagging when AVAudioPlayer plays

与世无争的帅哥 提交于 2019-12-04 06:18:22
问题 I'm creating a game where the user controls a character with a jetpack. When the jetpack intersects a diamond, I add the diamond to their total and then play a sound. However, the sound makes the game pause for a tenth of a second or so and disrupts the flow. This is the code I'm using: var diamondSound = NSBundle.mainBundle().URLForResource("diamondCollect", withExtension: "wav")! var diamondPlayer = AVAudioPlayer?() class GameScene: SKScene{ override func didMoveToView(view: SKView) { do {

FileManager cannot find audio file

北城余情 提交于 2019-12-04 05:29:33
问题 Helloo! My ultimate goal is to create a UITableViewController with recordings made in-app, using FileManager to traverse the /Documents/ directory and list all the recordings found there. The recording and playback are functioning just fine with one recording, with the following setup: // In VC#1 func setupRecorder(){ let audioSession:AVAudioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord) } catch { print("Audio Setup Error: \

How to lower the volume of music in swift?

∥☆過路亽.° 提交于 2019-12-04 05:10:20
I am creating a SpriteKit Game with background music looping. The problem is that the music is too loud. How do I lower the volume? Here is the code I used to set up the music var backGroundMusic = AVAudioPlayer() var bgMusicUrl:NSURL = NSBundle.mainBundle().URLForResource("BackGround", withExtension: "wav") backGroundMusic = AVAudioPlayer(contentsOfURL:bgMusicUrl, error: nil) backGroundMusic.numberOfLoops = (-1) backGroundMusic.prepareToPlay() backGroundMusic.play() Have you tried this? backGroundMusic.volume = 0.5 Volume goes from 0.0 to 1.0 (full volume). https://developer.apple.com/library

Problems with AVAudioPlayer

烂漫一生 提交于 2019-12-04 05:05:23
I'm new to the iPhone-Development. I want to play a Sound when an UIButton is tapped. I tried the following: ViewController.h: @interface JahrenzeitenViewController : UIViewController <AVAudioPlayerDelegate> { UIButton *button_PlaySound; AVAudioPlayer *audioPlayer; } @property (nonatomic, retain) IBOutlet UIButton *button_PlaySound; ViewController.m - (IBAction)playSound { //[audioPlayer release]; //audioPlayer = nil; NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"wav"]; NSURL *audioFileURL = [NSURL fileURLWithPath:audioFilePath]; NSError *error = nil;

Swift: Keep playing sounds when the device is locked

白昼怎懂夜的黑 提交于 2019-12-04 05:02:57
问题 I'm using the following code to play a sound off a URL from the internet: var audioPlayer = AVPlayer() ... let audioSession = AVAudioSession.sharedInstance() audioSession.setCategory(AVAudioSessionCategoryAmbient, error: nil) let url = trackFileName let playerItem = AVPlayerItem( URL:NSURL( string:url ) ) audioPlayer = AVPlayer(playerItem:playerItem) audioPlayer.rate = 1.0; player.play() I'm trying to make sure it keeps playing in the background which is the reason why I'm using

How can I use AVAudioPlayer to play audio faster *and* higher pitched?

若如初见. 提交于 2019-12-04 04:38:55
Statement of Problem: I have a collection of sound effects in my app stored as .m4a files (AAC format, 48 KHz, 16-bit) that I want to play at a variety of speeds and pitches, without having to pre-generate all the variants as separate files. Although the .rate property of an AVAudioPlayer object can alter playback speed, it always maintains the original pitch, which is not what I want. Instead, I simply want to play the sound sample faster or slower and have the pitch go up or down to match — just like speeding up or slowing down an old-fashioned reel-to-reel tape recorder. In other words, I

Force audio file playback through iPhone loud speaker using Swift

ぐ巨炮叔叔 提交于 2019-12-04 04:04:49
I have an App that records and then plays back an audio file. Currently the audio playback is playing through the earpiece speaker. Could someone tell me how Swift would handle coding this to force the audio out the loud speaker instead? Below is a one of the instances I'm using to play the audio file: @IBAction func playAudioVader(sender: UIButton) { playAudioWithVariablePitch(-1000) } func playAudioWithVariablePitch(pitch: Float){ audioPlayer.stop() audioEngine.stop() audioEngine.reset() var audioPlayerNode = AVAudioPlayerNode() audioEngine.attachNode(audioPlayerNode) var changePitchEffect =