avaudioplayer

Trying to understand AVAudioPlayer and audio level metering

不打扰是莪最后的温柔 提交于 2019-12-21 16:17:56
问题 I'm trying to understand AVAudioPlayer and audio level metering. What I have below is an object "AudioPlayer" that is playing a short audio sound. Now I want to output the power of this sound (decibels). Somehow I don't think I'm doing this right. audioPlayer.meteringEnabled = YES; [audioPlayer play]; int channels = audioPlayer.numberOfChannels; [audioPlayer updateMeters]; for (int i=0; i<channels; i++) { //Log the peak and average power NSLog(@"%d %0.2f %0.2f", i, [audioPlayer

AudioPlayer and lockscreen/control center control Swift [closed]

最后都变了- 提交于 2019-12-21 15:15:43
问题 Closed. This question is off-topic. It is not currently accepting answers. 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

Problems with AVAudioPlayer

不羁岁月 提交于 2019-12-21 10:45:30
问题 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"

audioPlayerDidFinishPlaying never triggers

◇◆丶佛笑我妖孽 提交于 2019-12-21 09:29:36
问题 I created a custom class to handle audio playback. AudioPlayback.h #import <Foundation/Foundation.h> #import "AVFoundation/AVAudioPlayer.h" #import <AVFoundation/AVFoundation.h> @interface AudioPlayback : NSObject <AVAudioPlayerDelegate> { AVAudioPlayer *player; BOOL playing; NSTimeInterval duration; } @property (nonatomic, assign) AVAudioPlayer *player; @property (readonly) BOOL playing; @property (readonly) NSTimeInterval duration; -(NSTimeInterval)GetSoundFileDuration:(NSString *) sound

AVAudioPlayer working in Simulator, but not on device

天大地大妈咪最大 提交于 2019-12-21 06:59:13
问题 My mp3 playing code is: NSError *error; soundObject = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:audioPathString] error:&error]; if (soundObject == nil) NSLog(@"%@", [error description]); soundObject.delegate = self; soundObject.numberOfLoops = 0; soundObject.volume = 1.0; NSLog(@"about to play"); [soundObject prepareToPlay]; [soundObject play]; NSLog(@"[soundObject play];"); The mp3 used to play fine, and it still does on the simulator . But not on the device. I've

AVAudioPlayer working in Simulator, but not on device

时光毁灭记忆、已成空白 提交于 2019-12-21 06:59:03
问题 My mp3 playing code is: NSError *error; soundObject = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:audioPathString] error:&error]; if (soundObject == nil) NSLog(@"%@", [error description]); soundObject.delegate = self; soundObject.numberOfLoops = 0; soundObject.volume = 1.0; NSLog(@"about to play"); [soundObject prepareToPlay]; [soundObject play]; NSLog(@"[soundObject play];"); The mp3 used to play fine, and it still does on the simulator . But not on the device. I've

check avaudioplayer's current playback time

淺唱寂寞╮ 提交于 2019-12-21 05:11:27
问题 Is this the right way to check AVAudioPlayer's current playback time. [audioPlayer play]; float seconds = audioPlayer.currentTime; float seconds = CMTimeGetSeconds(duration); How I can code after [audioPlayer play]; that when currentTime is equal to 11 seconds then [self performSelector:@selector(firstview) withObject:nil]; and after firstview when currentTime is equal to 23 seconds [self performSelector:@selector(secondview) withObject:nil]; 回答1: You could set up a NSTimer to check the time

Swift: iPhone's volume is low when trying to change speech to iPhone's voice in swift

谁说我不能喝 提交于 2019-12-21 04:25:28
问题 I am trying Speech recognition sample. If I started to recognise my speech via microphone, then I tried to get iPhone's voice of that recognised text. It is working. But, voice is too low. Can u guide me on this? Rather than, if I am trying in simple button action, with AVSpeechUtterance code, volume is normal. After that, If I go for startRecognise() method, volume is too low. My Code func startRecognise() { let audioSession = AVAudioSession.sharedInstance() //2 do { try audioSession

swift 3 using speech recognition and AVFoundation together

自闭症网瘾萝莉.ら 提交于 2019-12-21 04:17:07
问题 I am successfully able to use Speech (speech recognition) and I can use AVFoundation to play wav files in Xcode 8/IOS 10. I just can't use them both together. I have working speech recognition code where I import Speech. When I import AVFoundation into the same app and use the following code, there is no sound and no errors are generated: var audioPlayer: AVAudioPlayer! func playAudio() { let path = Bundle.main.path(forResource: "file.wav", ofType: nil)! let url = URL(fileURLWithPath: path)

swift 3 using speech recognition and AVFoundation together

百般思念 提交于 2019-12-21 04:17:01
问题 I am successfully able to use Speech (speech recognition) and I can use AVFoundation to play wav files in Xcode 8/IOS 10. I just can't use them both together. I have working speech recognition code where I import Speech. When I import AVFoundation into the same app and use the following code, there is no sound and no errors are generated: var audioPlayer: AVAudioPlayer! func playAudio() { let path = Bundle.main.path(forResource: "file.wav", ofType: nil)! let url = URL(fileURLWithPath: path)