avaudioplayer

Detect when music player is being paused

荒凉一梦 提交于 2020-01-06 13:53:25
问题 I wonder if it's possible to detect when the the music in my "iPod" on the phone is being paused, not if it's paused or currently playing, just the moment when the music is being paused. I guess i should be using AVAudio ? Thanks! 回答1: MPMusicPlayerController has a method: +(MPMusicPlayerController *)iPodMusicPlayer; The iPod music player employs the iPod app on your behalf. On instantiation, it takes on the current iPod app state and controls that state as your app runs. Specifically, the

Detect when music player is being paused

自作多情 提交于 2020-01-06 13:53:13
问题 I wonder if it's possible to detect when the the music in my "iPod" on the phone is being paused, not if it's paused or currently playing, just the moment when the music is being paused. I guess i should be using AVAudio ? Thanks! 回答1: MPMusicPlayerController has a method: +(MPMusicPlayerController *)iPodMusicPlayer; The iPod music player employs the iPod app on your behalf. On instantiation, it takes on the current iPod app state and controls that state as your app runs. Specifically, the

What should I do to call audioPlayerDidFinishPlaying:

て烟熏妆下的殇ゞ 提交于 2020-01-06 05:40:10
问题 I wrote this source program . But I can't call audioPlayerDidFinishPlaying: method. After playing the sound, which crashes by "exc_bad_access" error after a few seconds. .h file #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface SecondViewController : UIViewController< AVAudioPlayerDelegate>{ AVAudioPlayer *aPlayer; } @end .m file -(void)playSound{ NSString *soundName = @"red"; NSError *error = nil; NSURL *soundUrl = [[NSBundle mainBundle] URLForResource:soundName

Memory Leak - NSString & NSURL

三世轮回 提交于 2020-01-05 22:42:09
问题 @property ( nonatomic, strong ) NSURL * urlPath; self.urlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"bark" ofType:@"caf"]]; Running ARC, deployment target 4.3. Instruments gives a leak on the self.urlPath = line. The self.urlPath is used later on after the view has appeared to setup the AVSoundPlayer. There is NO leak indicated now on the soundplayer, only on this NSURL line. The audio plays, but when the view is pop'd a memory leak occurs. Any ideas as I've been at

AVAudioPlayer Object Sound Not Playing - Swift

為{幸葍}努か 提交于 2020-01-05 08:11:45
问题 I have created an object class of AVAudioPlayer below in order to play a noise: class MusicAudio: NSObject, AVAudioPlayerDelegate { var bassAudio : AVAudioPlayer! = AVAudioPlayer() override init() { super.init() let bassAudioPath = NSBundle.mainBundle().pathForResource("Raw", ofType:"mp3") let fileURL = NSURL(fileURLWithPath: bassAudioPath!) bassAudio = AVAudioPlayer(contentsOfURL: fileURL, error: nil) bassAudio.currentTime = 0 bassAudio.volume = 1.0 bassAudio.delegate = self } func

AVAudioPlayer Object Sound Not Playing - Swift

给你一囗甜甜゛ 提交于 2020-01-05 08:11:09
问题 I have created an object class of AVAudioPlayer below in order to play a noise: class MusicAudio: NSObject, AVAudioPlayerDelegate { var bassAudio : AVAudioPlayer! = AVAudioPlayer() override init() { super.init() let bassAudioPath = NSBundle.mainBundle().pathForResource("Raw", ofType:"mp3") let fileURL = NSURL(fileURLWithPath: bassAudioPath!) bassAudio = AVAudioPlayer(contentsOfURL: fileURL, error: nil) bassAudio.currentTime = 0 bassAudio.volume = 1.0 bassAudio.delegate = self } func

OSStatus error 1685348671 AVAudioPlayer

拟墨画扇 提交于 2020-01-05 04:23:06
问题 I'm trying to download mp3 file with Alamofire and save it to desired location. Then, from that location, I'm trying to play that file, but it gives me an error. This is download function func downloadSong(song: Song, completion: @escaping(Bool) -> ()) { var headers: HTTPHeaders = [:] if let authorizationHeader = Request.authorizationHeader(user: Constants.authName, password: Constants.authKey) { headers[authorizationHeader.key] = authorizationHeader.value } let destination: DownloadRequest

SpeakHere voice recorder fails after AVAudioPlayer in iOS

a 夏天 提交于 2020-01-04 17:09:25
问题 I am using Apple's SpeakHere example in my project. I can record voice and play without problems.. The problem occurs when I change the view controller where I am using AVAudioPlayer to play recorded voices.. If I go back to SpeakHereViewController to record once again, then it keeps saying "ERROR: metering failed". Why is it happening? Thanks in advance. 来源: https://stackoverflow.com/questions/17691616/speakhere-voice-recorder-fails-after-avaudioplayer-in-ios

Why does audio work in the simulator but not on my iPad?

血红的双手。 提交于 2020-01-04 03:13:51
问题 I am working on creating a very simple app. 2 buttons, both play sound. Each clip lasts 1 second and responds to "TouchUpInside". They are .caf files that I converted in iTunes. Here is my code, once again, it works in the simulator but not on the device: enter code here- (void)viewDidLoad { NSLog(@"InView did load"); AudioServicesCreateSystemSoundID ((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"bigaif" ofType:@"caf"]], &systemSoundID);

background device music gets stopped as app starts ios

 ̄綄美尐妖づ 提交于 2020-01-03 16:49:29
问题 I am playing music in iphone and when I run my application it should not stop background device music and should stop its own music instead background music is getting stop. I want to do same as candy crush app. What should I do to resolve this? Please help me var isOtherAudioPlaying = AVAudioSession.sharedInstance().otherAudioPlaying println("isOtherAudioPlaying>>> \(isOtherAudioPlaying)") if(isOtherAudioPlaying == false) { audioPlayer1!.play() } 回答1: Since the default is