avaudioplayer

Check if video has audio or not

我的未来我决定 提交于 2019-12-24 13:59:02
问题 I have to make decision if a video file (streaming from server) has audio or not. If it has audio then I have to stop already playing audio file and start video else play video with already running audio. I have managed to pause audio before playing video but how can I check audio in a video? I am using AVAudioPlayer to play audio and MPMoviePlayerViewController to play video. I have searched a lot on google but no success. Any help will be appreciated. 回答1: http://developer.apple.com/library

application:didReceiveRemoteNotification:fetchCompletionHandler: not in UIApplicateStateBackground when called

醉酒当歌 提交于 2019-12-24 10:44:08
问题 I've been puzzled by this for weeks and still no idea what's going on. The app is setup with background mode to play audio and fetch data. The app is backgrounded and the screen is on lockscreen. The method application:didReceiveRemoteNotification:fetchCompletionHandler: gets called when a remote push arrives. The odd thing is that the application state is different sometimes. Here are the two outcomes from different sessions: A) Remote push comes in, application state is

AVAudioPlayer affects system sounds

心不动则不痛 提交于 2019-12-24 09:37:20
问题 I use this code to play a short sound effect. This happens when user clicks the return button of the keyboard, which makes the keyboard click sound effect louder than usual. Is it possible to play the effect at certain volume without affecting system sounds? - (void)playCorrectAnswerSound { NSString *path = [[NSBundle mainBundle] pathForResource:@"correct" ofType:@"mp3"]; NSURL *urlPath = [NSURL fileURLWithPath:path]; self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:urlPath error

iPhone AVAudioPlayer loop stuttering?

白昼怎懂夜的黑 提交于 2019-12-24 07:24:50
问题 I have a sound that is about 2 seconds long which I have set it's it's numberOfLoops property to -1, but it has a .5 second lag between loops i want the sound to fade into itself when it is looping. Help please! 回答1: You can try to use some low-level API to work with sound.I had good results using OpenAL on the iPhone. Also ideal looping is quiet hard, because your audio file should have, for example almost equivalent parameters(frequency, for example) to make people not to hear when the file

MPMoviePlayer sound working in Simulators and ipad device, but not Working in iPhone Device

こ雲淡風輕ζ 提交于 2019-12-24 05:01:45
问题 I have a problem with MPMoviePlayerController, i.e. I am playing the live stream url in (m3u8 format) MPMoviePlayer like below: player = [[MPMoviePlayerController alloc] initWithContentURL:audioUrl]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:player]; if ([player respondsToSelector:@selector(loadState)]) { // Set movie player layout [player setMovieSourceType:MPMovieSourceTypeStreaming]

AVAudioPlayer doesn't play audio in iPhone 5 when locked

穿精又带淫゛_ 提交于 2019-12-24 00:58:21
问题 Using AVAudioPlayer I'm trying to play sounds while the iphone player is playing. Also when device is locked. The thing is, that in iPhone 4s ios 7 - works fine. But on iPhone 5 with 6 and 7 ios nothing happens. In the -Info.plist in Required background modes I wrote App plays audio or streams audio/video using AirPlay in Player.h implemented: @property (nonatomic, strong) AVAudioPlayer *notificationPlayer; <AVAudioPlayerDelegate, AVAudioSessionDelegate> with #import <AVFoundation

I want to play mp3 files on my server with AVAudioPlayer

会有一股神秘感。 提交于 2019-12-24 00:44:23
问题 I want to play mp3 files on my server with AVAudioPlayer I've tried this code, but it does not work. -(IBAction)playSound { NSString *path = [[NSBundle mainBundle] pathForResource:@"http://www.domain.com/audio/test.mp3"]; AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; theAudio.delegate = self; [theAudio play]; } 回答1: NSBundle can only select the files in the apps bundle, not the ones on the internet. Make this the path NSString

NSBundle finds mp3 file but not m4a when trying to instantiate AVAudioPlayer

六眼飞鱼酱① 提交于 2019-12-23 19:39:19
问题 I have a simple app that is supposed to play a audio file. Whenever I load a mp3 file to my NSURL is works fine and the AVAudioPlayer gets to play the song. However, when I change to a m4a file, the NSString path returns nil, like it is not able to find the path to my file, and thus the NSURL is not formed. The m4a file is of course there, in the project. It follows below the code, but I don't think is a code issue. Any ideias? Thanks. NSString *path = [[NSBundle mainBundle] pathForResource:@

Playing AVAudio from iPod Library while device is locked

好久不见. 提交于 2019-12-23 18:39:16
问题 Just a quick question. I've set up my program to be able to play AVAudioPlayer and AVPlayer in the background, which is working fine. I can play a song, lock my screen and the sound will continue to play. What I'm having trouble with is calling [AVPlayer play] whilst my screen is ALREADY locked. This ultimately results in no music being played. 回答1: You need to tell your player to listen for control events: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[UIApplication

How to start playing AVAudioPlayer while downloading?

亡梦爱人 提交于 2019-12-23 15:20:00
问题 I have a mp3 track at a URL http://mysite.com/MP3/track1.mp3. Downloading it to a local path with NSURLConnection and NSDocumentDirectory. I would like to start playing this track as soon as possible and not after it is completely downloaded. Is there a while to accomplish this? I have tried setting a "X" size limit, and once the download hits that number to start playing the track. But this only plays up to the point where it was initialized at the "X" size. Thanks in advance. - (void