avaudioplayer

Swift 3 iOS - Synchronised Pause with AVAudioPlayer

爱⌒轻易说出口 提交于 2019-12-12 04:37:33
问题 I am using AVAudioPlayer to play a set of synchronised MP3 files in a player style interface (Play/Pause/Stop). I am aware that I can synchronise playing them by using play(atTime:) but my question is, how do I synchronise pausing them? At the moment, to pause them, I am using: for (_, audioTrackPlayer) in audioTrackPlayers.enumerated() { audioTrackPlayer.pause() } But of course, they all pause one after the other. There is no equivalent pause(atTime:) function. So how can precise

Strange behaviour with AVAudioPlayer on the iPhone

你说的曾经没有我的故事 提交于 2019-12-12 04:36:33
问题 I'm attempting to play a sound using AVAudioPlayer. Should be simple, but I'm seeing some odd results. Code: NSString *path = [[NSBundle mainBundle] pathForResource:@"pop" ofType:@"wav"]; NSURL *url = [NSURL fileURLWithPath:path]; AVAudioPlayer *sound = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [sound play]; [sound release]; What I'm seeing is that the sound doesn't play when using the app normally. It plays only if I step through the code using the debugger, it doesn't

NSOSStatusErrorDomain Code=-54 for AVAudioPlayer

断了今生、忘了曾经 提交于 2019-12-12 04:16:58
问题 AVAudioPlayer has been giving me the following error on some local MP3 files: Error Domain=NSOSStatusErrorDomain Code=-54 "(null)" I'm downloading a zip file to the Documents directory, then unzipping using a library called SSZipArchive. In the Documents directory, a folder is created to contain the unzipped files. I was able to play entire albums without any issues. Everything was going fine until I start downloading certain files. I've looked for similar questions (osx), possibly stating

AVAudioPlayer Duration Changing

隐身守侯 提交于 2019-12-12 03:56:01
问题 My app uses AVAudioPlayer to play music files. It also has a UISlider to adjust where in the song it is playing back. However, there is an odd bug with the UISlider in that it seems to be changing the audioPlayer's duration. When a song is started, as part of the process, values are set like so: audioPlayer.currentTime = 0; seekingSlider.maximumValue = [audioPlayer duration]; seekingSlider.value = audioPlayer.currentTime; This works no problem. I then have an NSTimer that updates the

Swift: AVAudioPlayer using array suddenly mutes

五迷三道 提交于 2019-12-12 03:37:43
问题 I've written a small class that uses AVFoundation to play audio using an array. Basically an new element is appended to the array every time 'playAudio' is called. This allows multiple sounds to play without cutting each other off. Also, so that the array doesn't infinitely increase in size I've set it to cycle back to index 0 after filling 5 slots in the array. Now everything works perfectly but after 'audioPlayer' has been called a bunch of times, audio suddenly stops and I start getting

Add Action To Apple TV Remote Play/Pause Button

我只是一个虾纸丫 提交于 2019-12-12 03:36:13
问题 I have an AVAudioPlayer in my app and I am adding a function where the user can press the Play/Pause button on the remote to Play/Pause the AVAudioPlayer. I have this code in my App Delegate: func initializePlayButtonRecognition() { addPlayButtonRecognizer(#selector(AppDelegate.handlePlayButton(_:))) } func addPlayButtonRecognizer(_ selector: Selector) { let playButtonRecognizer = UITapGestureRecognizer(target: self, action:selector) playButtonRecognizer.allowedPressTypes = [NSNumber(value:

SKEmiterNode with AVAudioPlayer for music visuals

旧城冷巷雨未停 提交于 2019-12-12 03:35:53
问题 PLEASE SOMEONE HELP! I want to have my SKEmiterNode's scale(meaning size) get larger and smaller to the music i have built into the application using AVAudioPlayer. Right now this is pretty much all I have for the SKEmiterNode and it looks great: beatParticle?.position = CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.5) var beatParticleEffectNode = SKEffectNode() beatParticleEffectNode.addChild(beatParticle!) self.addChild(beatParticleEffectNode) All the looks are done in the .sks

Sound causing game to lag in swift sprite kit game?

痞子三分冷 提交于 2019-12-12 03:09:13
问题 New code class SceneTwo: SKScene, SKPhysicsContactDelegate { let flap = SKAction.playSoundFileNamed("flap.caf", waitForCompletion: false) let whack = SKAction.playSoundFileNamed("whack.caf", waitForCompletion: false) let tap = SKAction.playSoundFileNamed("tap.caf", waitForCompletion: false) Then I simply have put run(tap) run(flap) etc where necessary.. Hi just wondering if I am using the correct coding to play sounds in my game. For some context my game is similar to Flappy bird. One sound

AVAudioPlayer won't play existing file a second time

寵の児 提交于 2019-12-12 03:06:36
问题 I have searched a lot trying to figure this out - the code to me seems ok but the functionality doesn't reflect this. I have a View that is presented (its an Audio Recorder view). You can press record and it records to a file just fine (data exists in the file). I can then play the file back via the play button (the AVAudioPlayer is pointing to that file). However when I close/dismiss that view and come back to it - the file will not play when Play is tapped even though it should be exactly

AVAudioPlayer causes my game to lag

删除回忆录丶 提交于 2019-12-12 02:08:00
问题 I've made a simple game in Xcode where the character moves around the screen to collect coins, while avoiding getting hit by rocks. For the movement I use NSTimers which work fine. The problem occurs when I add sound effects. I use AVAudioPlayers for this and it makes the game lag a little bit. I commented them out to see if they caused the problem, and it seems to be the case. I've looked around here on Stack Overflow and on other sites, but I can't seem to find a good answer. Any help