Search Results

Search found 122 results on 5 pages for 'avaudioplayer'.

Page 3/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • How to find the leaky faucet that loads into Malloc 32kb

    - by Rob
    I have been messing around with Leaks trying to find which function is not being deallocated (I am still new to this) and could really use some experienced insight. I have this bit of code that seems to be the culprit. Every time I press the button that calls this code, 32kb of memory is additionally allocated to memory and when the button is released that memory does not get deallocated. What I found was that everytime that AVAudioPlayer is called to play an m4a file, the final function to parse the m4a file is MP4BoxParser::Initialize() and this in turn allocates 32kb of memory through Cached_DataSource::ReadBytes My question is, how do I go about deallocating that after it is finished so that it doesn't keep allocating 32kb every time the button is pressed? Any help you could provide is greatly appreciated! - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { //stop playing theAudio.stop; // cancel any pending handleSingleTap messages [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(handleSingleTap) object:nil]; UITouch* touch = [[event allTouches] anyObject]; NSString* filename = [g_AppsList objectAtIndex: [touch view].tag]; NSString *path = [[NSBundle mainBundle] pathForResource: filename ofType:@"m4a"]; theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; theAudio.delegate = self; [theAudio prepareToPlay]; [theAudio setNumberOfLoops:-1]; [theAudio setVolume: g_Volume]; [theAudio play]; }

    Read the article

  • Playing video and audio in iPhone not working...

    - by Scott
    So we have buttons linked up to display images/videos/audio on click depending on a check we do earlier. That part works fine. It knows which one to play, however, when we click the buttons for video and audio, nothing happens. The image one works fine. The video and audio are being taken for a URL online, they are not local, but everywhere said this was still possible. Here is a little snippet of the code where we play the two files: if ( [fName hasSuffix:@".png"]) { NSLog(@"PICTURE"); NSURL *url = [NSURL URLWithString: fName]; UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]]; self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; // self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"MainBG.jpg"]]; [self.view addSubview:[[UIImageView alloc] initWithImage:image]]; } if ( [fName hasSuffix:@".mp4"]) { NSLog(@"VIDEO"); //NSString *path = [[NSBundle mainBundle] pathForResource:fName ofType:@"mp4"]; //NSLog(path); NSURL *url = [NSURL fileURLWithPath:fName]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; [player play]; } if ( [fName hasSuffix:@".mp3"]) { NSLog(@"AUDIO"); NSURL *url = [NSURL fileURLWithPath:fName]; NSData *soundData = [NSData dataWithContentsOfURL:url]; AVAudioPlayer *avPlayer = [[AVAudioPlayer alloc] initWithData:soundData error: nil]; [avPlayer play]; } See anything wrong? By the way it compiles and runs, but nothing happens when we hit the button that executes that code.

    Read the article

  • video is not playing on ipad(device) when i use a separate audio track with it

    - by sujith1406
    In my application i need to play a video(silent ) together with another audio.i am using mpmovieplayercontroller for video and avaudioplayer for audio.the problem is on device (for ipad) the video is not playing .it is working perfect on ipad and iphone simulator .also on iphone .i am using ipad (os 3.2 ) installed.why is this so?? this is the code i am using NSString *trackname=[dict objectForKey:@"AudioFile"]; NSLog(@"track--->%@",trackname); NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:trackname ofType:@"mp4"]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:NULL]; if(error) { NSLog(@"%@",&error); } [player prepareToPlay]; [player play]; player.numberOfLoops=0; slider.maximumValue=player.duration; slider.minimumValue=0; [playpausebtn setBackgroundImage:[UIImage imageNamed:@"pausebutton.png"] forState:UIControlStateNormal]; timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateSlider) userInfo:nil repeats:YES]; NSString *videoFile = [[NSBundle mainBundle] pathForResource:@"video-track" ofType:@"mp4"]; moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:videoFile]]; [[moviePlayer view] setFrame: [videoView bounds]]; // frame must match parent view [videoView addSubview: [moviePlayer view]]; [videoView setBackgroundColor:[UIColor blackColor]]; moviePlayer.repeatMode=MPMovieRepeatModeOne; moviePlayer.controlStyle=MPMovieControlStyleNone; [moviePlayer play];

    Read the article

  • AVAudioPlayer currentTime problem

    - by StrAbZ
    Hi, I'm trying to use the audioplayer with a slider in order to seek into a track (nothing complicated). But I have a weird behavior... for some value of currentTime (between 0 and trackDuration), the player stop playing the track, and goes into "audioPlayerDidFinishPlaying:successfully:" with successfully to NO. And it did not go into "audioPlayerDecodeErrorDidOccur:error:" It's like it can't read the time i'm giving to it. For exemple the duration of the track is: 295.784424 seconds i set the currentTime to 55.0s (ie: 54.963878 or 54.963900 or 54.987755, etc... when printed as %f). The "crashes" always happen when the currentTime is 54.987755... and I really don't understand why... So if you have any idea... ^^

    Read the article

  • audioPlayerDidFinishPlaying not being called during scrolling UITableView

    - by Rob
    One of my views is a UITableView which acts as the delegate for an AVAudioPlayer and this table essentially plays sounds when you select a certain row with options to repeat the sound after its finished playing. However, I noticed that if I select a cell with repeat ON for a certain sound and then scroll through the UITableView to select a different sound, it will not call audioPlayerDidFinishPlaying (and therefore not repeat) until after scrolling has stopped. As soon as I stop scrolling, it repeats just fine. Or if I don't scroll at all, it repeats just fine. What could be happening during scrolling that the UITableView is no longer acting as the delegate and calling audioPlayerDidFinishPlaying? Any thoughts?

    Read the article

  • How do I force one method to be executed before another method?

    - by RexOnRoids
    I've got 2 methods. One method starts playing an audio file (.mp3), the other method updates a UIToolBar to show a button (PLAY or PAUSE). These two methods are called in the following order: //Adds some UIBarButtonItems to a UIToolBar [self togglePlayer]; //Uses AVAudioPlayer [audioPlayer play]; I call the methods in the above order so that the (pause) button will be shown at the time the song starts playing. But, the problem is that the song starts playing first, and the UIToolBar remains unchanged for quite a while (from 2 to 5 secs) until the button is added and shown. What I want is for the button to be shown at the same time the song starts playing (i.e. NO DELAY). Is there any way to do this?

    Read the article

  • How to play sounds in locked mode on iPhone

    - by Joe Mallik
    Everybody knows the standard procedure to keep your app alive, after the user pressed the lock button (silent sound). If I start a sound with AVAudioPlayer (before the iphone is locked), the sound plays till it's end (after locking). The app is still running. If I try to start another sound while the iPhone is locked, it will never get played. All the other things work as well but the sound doesn't. How can I play a sound while the iphone is locked?

    Read the article

  • Cannot play a recorded sound on device.

    - by B_
    I'm using the exact code from the iPhone Application Programming Guide Multimedia Support to use AVAudioRecorder to record a file to the disk and then AVAudioPlayer to load and play that file. This is working fine in the simulator but is not working on the device. The file gets loaded (we can see the NSTimeInterval) but does not play (play returns false). After it didn't work with the sample code from the website, we tried changing to a bunch of different codecs with no success. And of course, the sound is on. Thanks a bunch.

    Read the article

  • Button in App on iOS 4.2 won't work properly

    - by MatthiasC
    My app, written for the iPad contains several UIButtons. One of them starts and stops an AVAudioPlayer: hitting the button once starts the player, hitting it again stops it accordingly. Rinse and repeat. This all works nicely on iOS version pre 4.2. When installing the App on an iPad with iOS 4.2, the button turns on and off the audio player exactly once, then stops working properly: after hitting the button, it turns into its selected state, but it does not start the audio player (as it should) and hitting the button again doesn't return it to its default state, either. As previously said: it's all fine and dandy pre 4.2, the problem only arises on the most current OS version. XCode 3.2.4 iPad with iOS 4.2

    Read the article

  • Soundboard app: Play sound as long as the user is pressing the button

    - by Pantelis Proios
    I am making a soundboard app and i am using sounds with over 30sec duration. I am playing the sound by connecting in IB my action with a "touch down" event, however the sound keeps playing once started. I connected in the some button a "touch cancel" & "touch up outside" event that is supposed to stop the sound but for some reason it doesn't. Can anybody provide a solution to my problem? ---Edit--- Here is my code: -(IBAction)playSound:(id)sender { NSString *soundFile; soundFile = [[NSBundle mainBundle] pathForResource:@"testSound" ofType:@"mp3"]; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundFile] error:nil]; audioPlayer.volume = volumeSlider.value; audioPlayer.numberOfLoops = -1; [audioPlayer prepareToPlay]; [audioPlayer play]; } -(IBAction)stopSound:(id)sender { [audioPlayer stop]; }

    Read the article

  • sound not playing when i press the button and how to fix overlapping sounds

    - by alfredjunco
    the code is giving me an error"Unused variable'path'" and when i press a button there is no sound playing how do i fix this the aSound is in the h file - (void)playOnce:(NSString *)aSound; - (IBAction) beatButton50 { [self playOnce:@"racecars"]; } - (void)playOnce:(NSString *)aSound { NSString *path = [[NSBundle mainBundle] pathForResource:aSound ofType:@"caf"]; if([theAudio isPlaying]) { [theAudio stop]; } } - (void)playLooped:(NSString *)aSound { NSString *path = [[NSBundle mainBundle] pathForResource:aSound ofType:@"caf"]; if (!theAudio) { theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: path] error: NULL]; } [theAudio setDelegate: self]; // loop indefinitely [theAudio setNumberOfLoops: -1]; [theAudio setVolume: 1.0]; [theAudio play]; } - (void)stopAudio { [theAudio stop]; [theAudio setCurrentTime:0]; }

    Read the article

  • Testing background audio in the simulator

    - by Cactuar
    I'm experimenting with the new background audio service in iPhone OS 4.0 but I can't get it to work in the simulator. According to this page: iPhone Application Programming Guide: Executing Code in the Background it seems that all I have to do is add the a UIBackgroundModes key with an array containing audio to my Info.plist file and the audio my application plays should automatically continue when I switch to another app. I have done this but the audio still pauses as I switch to another app, when I switch back it continues where it left off. This is the code I'm using to play the sound: NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audio.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; audioPlayer.numberOfLoops = -1; if (audioPlayer == nil) NSLog(@"%@", [error userInfo]); else [audioPlayer play]; Has anyone gotten this to work? Could it be that it would work on an actual device and it's just a problem with the simulator? I'm a bit hesitant to install 4.0 on my phone since I've heard it's still very buggy. Wish I had another device to use only for development.

    Read the article

  • iphone-AVAudio Player Crashes

    - by user2779450
    I have an app that uses an avaudio player for two things. One of them is to play an explosion sound when a uiimageview collision is detected, and the other is to play a lazer sound when a button is pressed. I declared the audioplayer in the .h class, and I call it each time the button is clicked by doing this: NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"/lazer" ofType:@"mp3"]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; if (error) { NSLog(@"Error in audioPlayer: %@", [error localizedDescription]); } else { [audioPlayer prepareToPlay]; } [audioPlayer play]; This works fine, but after many uses of the game, the audio will stop play when i hit the button, and when a collision is detected, the game crashes. Here is my crash log: 2013-09-18 18:09:19.618 BattleShip[506:907] 18:09:19.617 shm_open failed: "AppleAudioQueue.41.2619" (23) flags=0x2 errno=24 (lldb) Suggestions? Could there be something to do with repeatedly creating an audio player? Alternatives maybe?

    Read the article

  • About AMR audio file playing issue on different devices

    - by user352537
    I have got a quite strange problem here. I am developing an IM software and need to play audio files recorded by another client on Android. The same audio file I've got can be played with AVAudioPlayer on 3GS(IOS 4.2.1) device and simulator 4.2. But when I tried by play it on iPhone4(iOS 4.3.3), the function "play" always return NO. I also tried with two iPhone devices, the audio files recorded by iPhone client can be played on both 3GS and iPhone4. So I asked the Android developers about the record parameters they've used. They said that the "AudioEncoder" used by them was "DEFAULT". There are also some other parameters as following: **private AudioEncoder() {} public static final int DEFAULT = 0; /** AMR (Narrowband) audio codec */ public static final int AMR_NB = 1; /** @hide AMR (Wideband) audio codec */ public static final int AMR_WB = 2; /** @hide AAC audio codec */ public static final int AAC = 3; /** @hide enhanced AAC audio codec */ public static final int AAC_PLUS = 4; /** @hide enhanced AAC plus audio codec */ public static final int EAAC_PLUS = 5;** Does anybody know what's the matter?

    Read the article

  • How stop mp3 playing started with audioplayer

    - by bucche
    Hi, My application consists of a table view. row1, row2, row3.... When a cell is touched a different mp3 starts to play (row1.mp3, row2.mp3, row3.mp3....). it works! but i have a problem: i am not able to stop previous mp3, so if i touch a second cell i have 2 mp3s playing... if i touch a third cell i have 3 mp3s and so on... i want to stop mp3 that started before and play mp3 that is related to touched cell... during my tries, i created a variable to show some alerts if the player plays or not and when i am "inside the if" i used [myAudioPlayer stop].. i see the correct alert but mp3 doesn't stop. here is my code - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *elementi = [[array objectAtIndex:indexPath.row] componentsSeparatedByString:@"|"]; NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@.mp3", [[NSBundle mainBundle] resourcePath],[elementi objectAtIndex:1]]]; NSError *error; myAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; myAudioPlayer.numberOfLoops = -1; if (inEsecuzione == 0) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"1" message:@"1" delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil]; [alert show]; [alert release]; [myAudioPlayer play]; inEsecuzione = 1; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"2" message:@"2" delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil]; [alert show]; [alert release]; [myAudioPlayer stop]; inEsecuzione = 0; } } as i wrote before, i am not able to stop previous mp3

    Read the article

  • iPhone: How many instances of AVAudioPlayer should I have for multiple sounds?

    - by foreyez
    So I'm using AvAudioPlayer to play multiple wav files. About 20 different sounds (each about 1 sec long), and you can think of each being played on a button press. Also I don't need them all to play simultaneously, i.e., one plays and you press another button to play another one (which stops the currently played one). What I'm wondering, should I have multiple instances of AVAudioPlayer (20 of them) and then preload the audio files, or should I just use one instance of AvAudioPlayer and each time a button is pressed, initialize the AvAudioPlayer with the sound url (or would this be too slow?) Thanks in advance!

    Read the article

  • How to make music plays from begging of the app until a viewcontroller has been presented?

    - by Carlos Vargas
    Hey guys I have a problem with an app Im making. The thing is I want to add it some background music, but I just want to add it in the main view. My app has 3 view controllers: Main View Controller, Second View Controller and Third View Controller. What I want is to start the music in the Main View Controller and stop it when the Third View Controller is presented. I think I have to start the music in my app delegate and from there stop it, am I right? I hope someone's got the answer. Best Regards Carlos Vargas

    Read the article

  • Audio Recording and Playback

    - by Siva
    Hi, I am new to iphone development. In my app, I want to record a voice and play the recorded voice. Now I am trying to do via speak here sample code, but i feel it is too hard to understand with AudioToolbox framework. Somebody saying AudioToolbox framework is too difficult to implement it. is there any other sample with other than AudioToolbox framework or which way is best to do that? Please help me!

    Read the article

  • Play Sound while UIImageView animating crashes the app?

    - by Rahul Vyas
    Hello all, I am having a strange problem in my app. I am creating a app in which i have 9 buttons on the view i want to play sound and animation same time. I am using UIImageview for this but i am having starnge behaviour sometimes sound play early and then animation runs.So how do i play them at same time? I am also having crash on device on a specific animation in which i have 60 jpg files. So what's the best way to do this?

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >