in my app, when I want to stop an audio recorder, works fine for iOS 5 an 6.0.x
[self.audioRecorder stop];
calling to the method audioRecorderDidFinishRecording
But in iOS 6.1.x, doesn't.
The app get stuck, and doesnt call to audioRecorderDidFinishRecording
any ideas? please
Related
I have implemented Audiostreamer class of Matt Gallagher in my application and it works fine in ios4. But when I switched to iOS5 the background playing is not working in there.
I have added UIBackground Modes and Application does not run in Background plist values to my application. So I think the issue is something else.
it wont work in simulator, you're not in simulator are you?
#j_mcnally iOS5 Simulator supports background playing.
#thoughtbreaker In Matt Gallagher there are some flows. Does your audio not play in the background at all or it stops after one track is finished playing.
If its not playing at all in the background than there may be buffering related problem...
You should use Background expiration handler, in your audioStateChange method, but only when app is in the background.
UIApplication *app = [UIApplication sharedApplication];
UIBackgroundTaskIdentifier bgTask = [app beginBackgroundTaskWithExpirationHandler:nil]
}];
You can check the background mode by setting a global flag in applicationDidEnterBackground method
Also invalidate the handler in your audioStart Playing method
[app endBackgroundTask:bgTask];
I am trying to capture video using AVCaptureMovieFileOutput. For that I am using sample code of apple. I don't have great uderstanding on this but for start video capture I am using following code:
-(void)startRecordingWithOrientation:(AVCaptureVideoOrientation)videoOrientation;
{
AVCaptureConnection *videoConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self movieFileOutput] connections]];
if ([videoConnection isVideoOrientationSupported])
[videoConnection setVideoOrientation:videoOrientation];
[[self movieFileOutput] startRecordingToOutputFileURL:[self outputFileURL] recordingDelegate:self];
// After this method my session say recording is yes.
}
Here:
[self movieFileOutput] returning a object of AVCaptureMovieFileOutput.
Now I have delegate methods for handling further things.
The problamatic part is Delegate Methods for AVCaptureMovieFileOutput are being called sometime and some time this doesn't.
Max probably when I pop this page after first recording and then I come back on this screen I face that delegate methods are not being called.
I have to Kill application and this works for new recording.
Please tell me the solution.
EDIT: The delegate method calls only once when I delete application and than reinstall app. After that this never get called. Even If I don't capture video and come on the screen and go back delegate don't get called. I am using apple's AVCam demo and added a screen before recorder screen.
Are you sure that the file you trying to save doesnt exist yet?
If it does, movie capture will fail to start, hence no delegane methods will be called.
I ran into a problem... perhaps someone bumped into something similar: I have an application that uses a MPMoviePlayerController, and used to work perfectly well.
Trying to compile and run it with new Xcode 4.2 using iPhone 5 Simulator, MPMoviePlayerController is not sending notifications when I load a movie. Looks like it fails to properly detect the video file.
The code looks more or less like that (simplified code):
// First I'm initializing the player with a URL from a file
MPMoviePlayerController *player;
player = [[MPMoviePlayerController alloc] init];
player.shouldAutoplay = NO;
NSURL *url = [NSURL fileURLWithPath:path];
player.contentURL = url;
// Then I'm adding an observer in order to wait for the player to find movie duration
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(durationAvailable:)
After the above, I'm waiting in a loop for the notification to get called, by waiting for about 10 seconds, during which I'm calling the run loop.
Using the same code, same Xcode 4.2 version, but with iPhone 4.3 Simulator, after about a second the notification gets called, and I can read the player duration. However, when running the exact same code on iPhone 5 Simulator, the notification function never gets called, and if I try to read the movie duration afterwards it contains 0.
Any idea?
Thanks,
Ariel
OK, I managed to find a workaround to the problem.
Apparently, adding this line after adding the observer does the trick:
[player pause];
It looks like if you don't "activate" the player somehow, the notifications will not be fired. In my case, I just wanted to get a notification for the duration of the movie without starting a playback, and it worked well in versions prior to iOS5, but it looks like they changed the behavior. Anyway, the above line solves the problem.
Ariel
try this MPMoviePlayerPlaybackStateDidChangeNotification :
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(stop)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
If a UILocalNotification fires with a sound set, and the user taps "Cancel" on the notification alert, the sound is stopped. But if the user taps "View", iOS then delivers the notification to the app and the sound keeps on playing. Is there any way to cancel this sound from the app? Canceling the notification in the app once the notification is delivered doesn't work (I didn't expect it to, the notification has already been delivered after all), and since I don't have the sound's system sound ID (and I didn't allocate it in the first place), I can't call AudioServicesDisposeSystemSoundID (can I?).
Is it possible to stop a UILocalNotification sound from playing if the user taps the Action button of the notification's alert?
It does not stop on the device too (5.1)
I have been trying to fix it but I can't figure it out.
I actually got it to stop on the simulator using this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
[[UIApplication sharedApplication] cancelLocalNotification:localNotif];
}
return YES;
}
but It still doesn't stop on the device
Apparently the problem only exists on the simulator (iOS 4.2 sdk), not on the actual device.
It can be handled in application delegate method as follows, if the user taps the Action button of the notification's alert, then the following method will be called, there we can cancel the notification
- (void)application:(UIApplication *)app
didReceiveLocalNotification:(UILocalNotification *)notif {
[[UIApplication sharedApplication]cancelLocalNotification:notif];
}
I had the same problem when initially testing with an iPhone 4.
The problem appears to have gone away as of iOS 8 and now Local Notification Sounds stop when canceled after transitioning to the App.
iPhone4 [ iOS - 7.1.2 ] - Local Notification sound keeps playing in App no matter what
iPhone6 [ iOS - 8.1.1 ] - Local Notification sound stop when canceled programmatically
From what I can infer, it appears a fix exists somewhere in iOS 8.x
(Alas I didn't manage to find any documentation or release notes on the matter.)
The Problem becomes a non-issue for apps focusing on iOS 8
(provided you cancel the Local Notification coming in)
I'm working on an iPhone iOS4 application that incorporates playing music from the user's iPod library. I also want to keep track of what songs have been played and be able to change the song randomly, even while in the background. So I set the music player using:
[self setMusicPlayer: [MPMusicPlayerController iPodMusicPlayer]];
Now, I want this application to continue to run and play music in the background, so I have set:
Required background modes: App plays audio
The problem I'm having is that my application loses control when it is moved into the background (when applicationDidEnterBackground is called, ie. on app switches). Since I'm using the iPodMusicPlayer the music continues to play but my app does not have control and therefore can't track or change the song.
Now, the Apple documentation states that your application should continue to execute in the background using this required background modes tag, but mine does not. Is it because I'm using MPMusicPlayer? Is there any way to get around it? Any ideas?
PS. I'm also trying to get the remote locked and multitasking iPod controllers to work with my application. I'm using the code below, but remoteControlReceivedWithEvent never gets called! Does it work with MPMusicPlayer? I've only seen it with AVAudioPlayer.
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
NSLog(#"remoteControlReceivedWithEvent");
switch (event.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(#"Play Pause");
break;
case UIEventSubtypeRemoteControlNextTrack:
NSLog(#"Next");
break;
default:
break;
}
}
- (BOOL)canBecomeFirstResponder {
NSLog(#"canBecomeFirstResponder");
return YES;
}
- (void) viewWillAppear:(BOOL)animated{
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
You are correct. Your iPhone app will not run in the background while using MPMusicPlayerController. This will also prevent you from receiving remote control events.
If you want to play audio from the iPod library and have your app continue running in the background, you must use the lower-level AVPlayer class.