avaudioplayer

AVPlayer Volume Control

若如初见. 提交于 2019-12-19 18:49:32
问题 I want to create a button that mutes the audio from an AVPlayer. Why can´t I use .volume with AVPlayer, only with AVAudioPlayer? Is there another way to change the volume? e.g music.volume = 0.0; Thanks for your answers. 回答1: Starting in iOS 7, simply call: myAvPlayer.volume = 0; Otherwise, you'll have to use the annoying setAudioMix solution. I'm detecting support for this in my app as follows: if ([mPlayer respondsToSelector:@selector(setVolume:)]) { mPlayer.volume = 0.0; } else { NSArray

Swift AVAudioPlayer wont play audio recorded with AVAudioRecorder

浪尽此生 提交于 2019-12-19 12:48:13
问题 I have built an app that records an audio clip, and saves it to a file called xxx.m4a . Once the recording is made, I can find this xxx.m4a file on my system and play it back - and it plays back fine. The problem isn't recording this audio track. My problem is playing this audio track back from within the app. // to demonstrate how I am building the recordedFileURL let currentFileName = "xxx.m4a" let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) let

Audio Information of Current Track iOS Swift

不想你离开。 提交于 2019-12-19 11:18:39
问题 Let's say a track is playing (through any app), and I want to get the song information, such as the name. It shows up on your screen when you lock the phone, along with the album cover. How can I get that information using swift? 回答1: Here is example function to get audio Info: import MediaPlayer var url:NSURL! let audioInfo = MPNowPlayingInfoCenter.defaultCenter() var nowPlayingInfo:[NSObject:AnyObject] = [:] func fetchMP3Info() { let playerItem = AVPlayerItem(URL: url) //this will be your

Independent Volume control of AVAudioPlayer and MPMusicPlayerController in iOS App.

独自空忆成欢 提交于 2019-12-19 10:33:10
问题 Within my application, I am playing downloaded audio using an AVAudioPlayer, while simultaneously playing audio from the user's iPod music library with an MPMusicPlayerController. I need to be able to adjust the Volume of the AVAudioPlayer instance so that it's louder than the audio coming from the MPMusicPlayerController. The problem is, when I adjust the Volume property of the AVAudioPlayer, it also adjusts the volume of the MPMusicPlayerController. Is there any solution which would allow

How to play the same sound overlapping with AVAudioPlayer?

懵懂的女人 提交于 2019-12-19 10:22:30
问题 This code plays the sound when the button is tapped but cancels the previous if it is pressed again. I do not want this to happen I want the same sound to overlap when repeatedly pressed. I believe it might be due to using the same AVAudioPlayer as I have looked on the internet but I am new to swift and want to know how to create a new AVAudioPlayer everytime the method runs so the sounds overlap. func playSound(sound:String){ // Set the sound file name & extension let soundPath = NSURL

Unable to Implement Forward Action in AVAudioplayer

不羁的心 提交于 2019-12-19 10:08:06
问题 I am using AVAudioplayer to play some audio files. I have some controls like forward and rewind. Rewind is working properly but forward is not. - (void)rewind { AVAudioPlayer *player = _rewTimer.userInfo; player.currentTime-= SKIP_TIME; [_rewTimer invalidate]; _rewTimer=nil; [self updateCurrentTime]; } - (void)ffwd { AVAudioPlayer *player = _ffwTimer.userInfo; player.currentTime-= SKIP_TIME; [player setCurrentTime:cTime]; [_ffwTimer invalidate]; _ffwTimer=nil; [self updateCurrentTime]; } As

AVAudioPlayer initialization error

拥有回忆 提交于 2019-12-19 06:18:14
问题 I initialize my AVAudioPlayer instance like: [self.audioPlayer initWithContentsOfURL:url error:&err]; url contains the path of an .m4a file The following error is displayed in the console when this line is called :" Error Domain=NSOSStatusErrorDomain Code=1685348671 "Operation could not be completed. (OSStatus error 1685348671.) " What is the reason for this error? 回答1: The error code is a four-char-code for "dta?" (you can use the Calculator app in programmer mode to convert the int values

AVAudioPlayer initialization error

烈酒焚心 提交于 2019-12-19 06:18:14
问题 I initialize my AVAudioPlayer instance like: [self.audioPlayer initWithContentsOfURL:url error:&err]; url contains the path of an .m4a file The following error is displayed in the console when this line is called :" Error Domain=NSOSStatusErrorDomain Code=1685348671 "Operation could not be completed. (OSStatus error 1685348671.) " What is the reason for this error? 回答1: The error code is a four-char-code for "dta?" (you can use the Calculator app in programmer mode to convert the int values

Record and play audio simultaneously in iOS

帅比萌擦擦* 提交于 2019-12-19 05:45:05
问题 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 pseudo code for what I am doing. If I do the same stuff after stop the recording everything works fine. AVAudioRecorder *recorder; //Initializing the recorder properly. [recorder record]; NSError *error=nil; NSUrl recordingPathUrl; //Contains the

iPhone: NSData representation of Audio file for Editing

人盡茶涼 提交于 2019-12-19 03:38:22
问题 I have been scratching my head since long now but not getting around to this. I haven't found a single example for Audio editing! I want to insert new Audio file in between somewhere in original Audio file, save it as new converted audio files. For this I have written following code. I got this idea from here. NSString *file1 = [[NSBundle mainBundle] pathForResource:@"file1" ofType:@"caf"]; // Using PCM format NSString *file2 = [[NSBundle mainBundle] pathForResource:@"file2" ofType:@"caf"];