Nido Apple

Recibe ayuda de expertos

Registrate y pregunta

Es gratis y fácil

Recibe respuestas

Respuestas, votos y comentarios

Vota y selecciona respuestas

Recibe puntos, vota y da la solución

Pregunta

0voto

audio no regresa despues de una llamad

hola y gracias por permitirme ser parte de este foro Estoy desarollando mi aplicacion y ya solucione unos problemas que me ayudo un administrador de este foro en un tema anterior. pero tengo un problema, decidi integrar un audio player para Shoutcast en mi aplicacion y ya he buscado en muchos foros y no encuentro la solucion: el audio no regresa despues de una llamada pero si me llaman y tengo la aplicacion abierta si regresa despues de colgar la llamada. Aqui les dejo el codigo por si alguien me puede ayudar. saludos @implementation AppDelegate @synthesize window; #pragma mark - #pragma mark Application lifecycle - (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions { sleep(2); // Override point for customization after application launch. // ----------- background ----------- // Set AudioSession NSError *sessionError = nil; [[AVAudioSessionsharedInstance] setDelegate:self]; [[AVAudioSessionsharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecorderror:&sessionError]; [[AVAudioSessionsharedInstance] setActive:YESerror:&sessionError]; [[AVAudioSessionsharedInstance] setCategory:AVAudioSessionCategoryPlaybackerror:nil]; //[[AVAudioSession sharedInstance] beginBackgroundTaskWithExpirationHandler: ^(void)]; // Pick any one of them // 1. Overriding the output audio route //UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; //AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride); // 2. Changing the default output audio route UInt32 doChangeDefaultRoute = 1; AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute); // --------- end Background ----------*/ returnYES; } - (void)applicationWillResignActiveUIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)endInterruptionWithFlagsNSUInteger)flags { // Validate if there are flags available. if (flags) { // Validate if the audio session is active and immediately ready to be used. if (AVAudioSessionInterruptionFlags_ShouldResume) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // Resume playing the audio. [[NSNotificationCenterdefaultCenter] postNotificationName: @"willEnterForeground" object: nil userInfo: nil]; NSLog(@"interrupt"); }); } } } - (void)applicationDidEnterBackgroundUIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. [[NSNotificationCenterdefaultCenter] postNotificationName: @"didEnterBackground" object: nil userInfo: nil]; } - (void)applicationWillEnterForegroundUIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActiveUIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminateUIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end

5 Respuestas

0voto

Peter Puntos289170
Si tienes la aplicación abierta y te llaman, funciona. ¿Entonces como no funciona? Saludos.

0voto

ChinChanPU Puntos420
lo que pasa es que si yo llamo el audio ya no regresa Solo regresa cuando me llaman Es medio extraño el problema pero asi me pasa

0voto

Peter Puntos289170
Me encontré este código que es similar a lo que estás utilizando, pero viene con un extra, a ver si te ayuda. BOOL wasPreviouslyInBackground = NO; - (void)applicationWillResignActive:(UIApplication *)application { /* Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ if([SUPMessageClient status] != STATUS_NOT_START) [SUPMessageClient stop]; wasPreviouslyInBackground = YES; } - (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ if(wasPreviouslyInBackground) [SUPMessageClient start]; Ya con un poco más de tiempo veo a detalle cual puede ser el problema y a ver si encuentro una solución para ello. ¿Estas usando storyboards, nibs, lo haces directo o en webviews? Por favor comparte un poco más detalles de como lo estás haciendo. También te dejo la referencia de Apple para controlar el audio. Saludos.

0voto

ChinChanPU Puntos420
hola Peter Gracias por tu ayuda Si estoy Usando StoryBoard y fijate que antes usaba .Xib y funcionaba exelete. los webview los uso para unas galerias, facebook, twitter y youtube.

0voto

Peter Puntos289170
Ok, pues prueba con el código que puse y nos cuentas. Saludos.

Por favor, accede o regístrate para responder a esta pregunta.

Otras Preguntas y Respuestas


Actividad Reciente

...