Search Results

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

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

  • How to make AVAudioPlayer play once it is stopped?

    - by Viral
    hi friends, I am using AVAudioplayer to play some sound. But once I make it stop using [player stop](where player is the object of AVAudioplayer] It is not starting again to play after some time when I call method [player play], So can any one tell me how to do the same in my application?? The play will again call using NSTimer method, after some delay of time. Thanks in advance...

    Read the article

  • iphone: Help with AudioToolbox Leak: Stack trace/code included here...

    - by editor guy
    Part of this app is a "Scream" button that plays random screams from cast members of a TV show. I have to bang on the app quite a while to see a memory leak in Instruments, but it's there, occasionally coming up (every 45 seconds to 2 minutes.) The leak is 3.50kb when it occurs. Haven't been able to crack it for several hours. Any help appreciated. Instruments says this is the offending code line: [appSoundPlayer play]; that's linked to from line 9 of the below stack trace: 0 libSystem.B.dylib malloc 1 libSystem.B.dylib pthread_create 2 AudioToolbox CAPThread::Start() 3 AudioToolbox GenericRunLoopThread::Start() 4 AudioToolbox AudioQueueNew(bool, AudioStreamBasicDescription const*, TCACallback const&, CACallbackTarget const&, unsigned long, OpaqueAudioQueue*) 5 AudioToolbox AudioQueueNewOutput 6 AVFoundation allocAudioQueue(AVAudioPlayer, AudioPlayerImpl*) 7 AVFoundation prepareToPlayQueue(AVAudioPlayer*, AudioPlayerImpl*) 8 AVFoundation -[AVAudioPlayer prepareToPlay] 9 Scream Queens -[ScreamViewController scream:] /Users/laptop2/Desktop/ScreamQueens Versions/ScreamQueens25/Scream Queens/Classes/../ScreamViewController.m:210 10 CoreFoundation -[NSObject performSelector:withObject:withObject:] 11 UIKit -[UIApplication sendAction:to:from:forEvent:] 12 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] 13 UIKit -[UIControl sendAction:to:forEvent:] 14 UIKit -[UIControl(Internal) _sendActionsForEvents:withEvent:] 15 UIKit -[UIControl touchesEnded:withEvent:] 16 UIKit -[UIWindow _sendTouchesForEvent:] 17 UIKit -[UIWindow sendEvent:] 18 UIKit -[UIApplication sendEvent:] 19 UIKit _UIApplicationHandleEvent 20 GraphicsServices PurpleEventCallback 21 CoreFoundation CFRunLoopRunSpecific 22 CoreFoundation CFRunLoopRunInMode 23 GraphicsServices GSEventRunModal 24 UIKit -[UIApplication _run] 25 UIKit UIApplicationMain 26 Scream Queens main /Users/laptop2/Desktop/ScreamQueens Versions/ScreamQueens25/Scream Queens/main.m:14 27 Scream Queens start Here's .h: #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <MediaPlayer/MediaPlayer.h> #import <AudioToolbox/AudioToolbox.h> #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> @interface ScreamViewController : UIViewController <UIApplicationDelegate, AVAudioPlayerDelegate, MFMailComposeViewControllerDelegate> { //AudioPlayer related AVAudioPlayer *appSoundPlayer; NSURL *soundFileURL; BOOL interruptedOnPlayback; BOOL playing; //Scream button related IBOutlet UIButton *screamButton; int currentScreamIndex; NSString *currentScream; NSMutableArray *screams; NSMutableArray *personScreaming; NSMutableArray *photoArray; int currentSayingsIndex; NSString *currentButtonSaying; NSMutableArray *funnyButtonSayings; IBOutlet UILabel *funnyButtonSayingsLabel; IBOutlet UILabel *personScreamingField; IBOutlet UIImageView *personScreamingImage; //Mailing the scream related IBOutlet UILabel *mailStatusMessage; IBOutlet UIButton *shareButton; } //AudioPlayer related @property (nonatomic, retain) AVAudioPlayer *appSoundPlayer; @property (nonatomic, retain) NSURL *soundFileURL; @property (readwrite) BOOL interruptedOnPlayback; @property (readwrite) BOOL playing; //Scream button related @property (nonatomic, retain) UIButton *screamButton; @property (nonatomic, retain) NSMutableArray *screams; @property (nonatomic, retain) NSMutableArray *personScreaming; @property (nonatomic, retain) NSMutableArray *photoArray; @property (nonatomic, retain) UILabel *personScreamingField; @property (nonatomic, retain) UIImageView *personScreamingImage; @property (nonatomic, retain) NSMutableArray *funnyButtonSayings; @property (nonatomic, retain) UILabel *funnyButtonSayingsLabel; //Mailing the scream related @property (nonatomic, retain) IBOutlet UILabel *mailStatusMessage; @property (nonatomic, retain) IBOutlet UIButton *shareButton; //Scream Button - (IBAction) scream: (id) sender; //Mail the scream - (IBAction) showPicker: (id)sender; - (void)displayComposerSheet; - (void)launchMailAppOnDevice; @end Here's the top of .m: #import "ScreamViewController.h" //top of code has Audio session callback function for responding to audio route changes (from Apple's code), then my code continues... @implementation ScreamViewController @synthesize appSoundPlayer; // AVAudioPlayer object for playing the selected scream @synthesize soundFileURL; // Path to the scream @synthesize interruptedOnPlayback; // Was application interrupted during audio playback @synthesize playing; // Track playing/not playing state @synthesize screamButton; //Press this button, girls scream. @synthesize screams; //Mutable array holding strings pointing to sound files of screams. @synthesize personScreaming; //Mutable array tracking the person doing the screaming @synthesize photoArray; //Mutable array holding strings pointing to photos of screaming girls @synthesize personScreamingField; //Field updates to announce which girl is screaming. @synthesize personScreamingImage; //Updates to show image of the screamer. @synthesize funnyButtonSayings; //Mutable array holding the sayings @synthesize funnyButtonSayingsLabel; //Label that updates with the funnyButtonSayings @synthesize mailStatusMessage; //did the email go out @synthesize shareButton; //share scream via email Next line begins the block with the offending code: - (IBAction) scream: (id) sender { //Play a click sound effect SystemSoundID soundID; NSString *sfxPath = [[NSBundle mainBundle] pathForResource:@"aClick" ofType:@"caf"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:sfxPath],&soundID); AudioServicesPlaySystemSound (soundID); // Because someone may slam the scream button over and over, //must stop current sound, then begin next if ([self appSoundPlayer] != nil) { [[self appSoundPlayer] setDelegate:nil]; [[self appSoundPlayer] stop]; [self setAppSoundPlayer: nil]; } //after selecting a random index in the array (did that in View Did Load), //we move to the next scream on each click. //First check... //Are we past the end of the array? if (currentScreamIndex == [screams count]) { currentScreamIndex = 0; } //Get the string at the index in the personScreaming array currentScream = [screams objectAtIndex: currentScreamIndex]; //Get the string at the index in the personScreaming array NSString *screamer = [personScreaming objectAtIndex:currentScreamIndex]; //Log the string to the console NSLog (@"playing scream: %@", screamer); // Display the string in the personScreamingField field NSString *listScreamer = [NSString stringWithFormat:@"scream by: %@", screamer]; [personScreamingField setText:listScreamer]; // Gets the file system path to the scream to play. NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: currentScream ofType: @"caf"]; // Converts the sound's file path to an NSURL object NSURL *newURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; self.soundFileURL = newURL; [newURL release]; [[AVAudioSession sharedInstance] setDelegate: self]; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; // Registers the audio route change listener callback function AudioSessionAddPropertyListener ( kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, self ); // Activates the audio session. NSError *activationError = nil; [[AVAudioSession sharedInstance] setActive: YES error: &activationError]; // Instantiates the AVAudioPlayer object, initializing it with the sound AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: nil]; //Error check and continue if (newPlayer != nil) { self.appSoundPlayer = newPlayer; [newPlayer release]; [appSoundPlayer prepareToPlay]; [appSoundPlayer setVolume: 1.0]; [appSoundPlayer setDelegate:self]; //NEXT LINE IS FLAGGED BY INSTRUMENTS AS LEAKY [appSoundPlayer play]; playing = YES; //Get the string at the index in the photoArray array NSString *screamerPic = [photoArray objectAtIndex:currentScreamIndex]; //Log the string to the console NSLog (@"displaying photo: %@", screamerPic); // Display the image of the person screaming personScreamingImage.image = [UIImage imageNamed:screamerPic]; //show the share button shareButton.hidden = NO; mailStatusMessage.hidden = NO; mailStatusMessage.text = @"share!"; //Get the string at the index in the funnySayings array currentSayingsIndex = random() % [funnyButtonSayings count]; currentButtonSaying = [funnyButtonSayings objectAtIndex: currentSayingsIndex]; NSString *theSaying = [funnyButtonSayings objectAtIndex:currentSayingsIndex]; [funnyButtonSayingsLabel setText: theSaying]; currentScreamIndex++; } } Here's my dealloc: - (void)dealloc { [appSoundPlayer stop]; [appSoundPlayer release], appSoundPlayer = nil; [screamButton release], screamButton = nil; [mailStatusMessage release], mailStatusMessage = nil; [personScreamingField release], personScreamingField = nil; [personScreamingImage release], personScreamingImage = nil; [funnyButtonSayings release], funnyButtonSayings = nil; [funnyButtonSayingsLabel release], funnyButtonSayingsLabel = nil; [screams release], screams = nil; [personScreaming release], personScreaming = nil; [soundFileURL release]; [super dealloc]; } @end Thanks so much for reading this far! Any input appreciated.

    Read the article

  • Audio queue start failed

    - by mobapps99
    Hi , i'm developing a project which has both audio streaming and playing audio from file. For audio streaming i'm using AudioStreamer and for playing from file i'm using avaudioplayer. Both streaming and playing works perfectly as long as the app is not interrupted by a phone call or sms. But when a call/sms comes after dismissing the call when i try to restart streaming i'm getting the error "Audio queue start failed" . This happens only when i have used avaudioplayer at least once and after that used streaming. When the avaudioplayer obeject is not created , in this scenario the there is no problem with resuming streaming after dismissing the call. My guess is that some thing is wrong with audioqueue. Help is very much appreciated.......

    Read the article

  • Open Source sound engine

    - by Steph Thirion
    When I started using SoundEngine (from CrashLanding and TouchFighter), I had read about a few people recommending not to use it, for it was, according to them, not stable enough. Still it was the only solution I knew of to play sounds with pitch and position control without learning C++ and OpenAL, so I ignored the warnings and went on with it. But now I'm starting to worry. The 2.2 SDK introduced AVFoundation. Using both SoundEngine from CrashLanding (for sounds) and AVAudioPlayer (for music), I found out SoundEngine behaves strangely when the only existing AVAudioPlayer is released (all sounds stop until a new AVAudioPlayer is initiated). Around the same time as the 2.2 SDK came out, the CrashLanding sample code was mysteriously removed from the ADC site. I'm worried there are more bad surprises to come. My question is, is anyone aware of an Open Source alternative to SoundEngine? Maybe even a C++ library that uses OpenAL?

    Read the article

  • Problem with playing a sound when a button is clicked.

    - by iSharreth
    in my code: import "MyViewController.h" import (IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL]; myExampleSound.delegate = self; [myExampleSound play]; } But it is showing a warning that Class MyViewController does not implement AVAudioplayerDelegate. Anyone please help. I had included the AVFoundation.Framework.

    Read the article

  • How do I keep music playing after the user presses the hold button on the iPhone?

    - by Carlos Vargas
    Hey guys how can I make an app keep playing an mp3 after pressed the hold/power button. Here is the code I use for preparing the AVAudioPlayer: - (void)PrepareAudio:(int)index { NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[_Audio objectAtIndex:Game]] ofType:@"mp3"]; NSURL *newURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; MusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: newURL error: nil]; [newURL release]; [MusicPlayer setVolume: 1.5]; } And this is the code when I press the button play: - (IBAction)PushPlay: (id)sender { if(!MusicPlayer.playing) [MusicPlayer play]; } Best Regards Carlos Vargas

    Read the article

  • Delay in playing a beep sound

    - by iSharreth
    -(IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL]; myExampleSound.delegate = self; [myExampleSound play]; } I want to play a beep sound when a button is clicked. I had used the above code. But it is taking some delay in playing the sound. Anyone please help.

    Read the article

  • code to play sound programmatically using a button on the iphone

    - by Brandon
    I am trying to figure out how to hook up a button to play a sound programmatically without using IB. I have the code to play the sound, but have no way of hooking the button up to play the sound? any help? here is my code that I'm using: - (void)playSound { NSString *path = [[NSBundle mainBundle] pathForResource:@"boing_1" ofType:@"wav"]; AVAudioPlayer* myAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path error:NULL]]; myAudio.delegate = self; myAudio.volume = 2.0; myAudio.numberOfLoops = 1; [myAudio play]; }

    Read the article

  • Play a beep that loop and change the frequency/speed

    - by Bono
    Hi all, I am creating an iphone application that use audio. I want to play a beep sound that loop indefinitely. I found an easy way to do that using the upper layer AVAudioPlayer and the numberOfLoops set to "-1". It works fine. But now I want to play this audio and be able to change the rate / speed. It may works like the sound played by a car when approaching an obstacle. At the beginning the beep has a low frequency and this frequency accelerate till reaching a continuous sound biiiiiiiiiiiip ... It seems this is not feasible using the high layer AVAudioPlayer, but even looking at AudioToolBox I found no solution. Does anybody have informations about how to do that? Thanks a lot for helping me!

    Read the article

  • [[NSURL alloc] initFileURLWithPath:(NSString)] returns null

    - by Ajay Pandey
    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"Opening" ofType:@"wav"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; NSLog(@"@ajay"); AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]; [fileURL release]; [audioPlayer play]; i have inserted a wav file in my project.But NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; returns NULL and console prints following: and application KILLS... Can someone help me?

    Read the article

  • Audio File continues to play even on leaving the view

    - by Swastik
    What I am doing is -(void)viewWillAppear:(BOOL)animated{ [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(clickEvent:) userInfo:nil repeats:YES]; } -(void)clickEvent:(NSTimer *)aTimer{ NSDate* finishDate = [NSDate date]; if([finishDate timeIntervalSinceDate: self.startDate] 11 && touched == NO){ NSString *mp3Path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"test.mp3"]; [self playMusicFile:mp3Path]; NSLog(@"Timer from First Page"); [aTimer invalidate]; //[touchCheckTimer release]; aTimer = nil; } else{ } -(void)playMusicFile:(NSString *)mp3Path{ NSURL *mp3Url = [NSURL fileURLWithPath:mp3Path]; NSError *err; AVAudioPlayer *audPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:mp3Url error:&err]; [self setAudioPlayer1:audPlayer]; if(audioPlayer1) [audioPlayer1 play]; [audPlayer release]; } Now, on pushing another view this audio file keeps playing in the background. Please help!

    Read the article

  • AVAudioRecorder Won't Record On Device

    - by Dyldo42
    This is my method: -(void) playOrRecord:(UIButton *)sender { if (playBool == YES) { NSError *error = nil; NSString *filePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"%d", [sender tag]] ofType:@"caf"]; NSURL *fileUrl = [NSURL fileURLWithPath:filePath]; AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error]; [player setNumberOfLoops:0]; [player play]; } else if (playBool == NO) { if ([recorder isRecording]) { [recorder stop]; [nowRecording setImage:[UIImage imageNamed:@"NormalNormal.png"] forState:UIControlStateNormal]; [nowRecording setImage:[UIImage imageNamed:@"NormalSelected.png"] forState:UIControlStateSelected]; } if (nowRecording == sender) { nowRecording = nil; return; } nowRecording = sender; NSError *error = nil; NSString *filePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"%d", [sender tag]] ofType:@"caf"]; NSURL *fileUrl = [NSURL fileURLWithPath:filePath]; [sender setImage:[UIImage imageNamed:@"RecordingNormal.png"] forState:UIControlStateNormal]; [sender setImage:[UIImage imageNamed:@"RecordingSelected.png"] forState:UIControlStateSelected]; recorder = [[AVAudioRecorder alloc] initWithURL:fileUrl settings:recordSettings error:&error]; [recorder record]; } } Most of it is self explanatory; playBool is a BOOL that is YES when it is in play mode. Everything works in the simulator however, when I run it on a device, [recorder record] returns NO. Does anyone have a clue as to why this is happening?

    Read the article

  • Sound does not working in Device

    - by diana
    In my app i write for record NSArray *filePaths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *recordingDirectory = [filePaths objectAtIndex: 0]; NSString *resourcePath = [recordingDirectory stringByAppendingString:@"/sound.caf"]; self.soundFileURL = [NSURL fileURLWithPath:resourcePath]; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; audioSession.delegate = self; [audioSession setActive: YES error: nil]; [[AVAudioSession sharedInstance] setCategory : AVAudioSessionCategoryRecorderror: nil]; NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; AVAudioRecorder *newRecorder = [[AVAudioRecorder alloc] initWithURL: soundFileURL settings: recordSettings error: nil]; [recordSettings release]; self.soundRecorder = newRecorder; [newRecorder release]; soundRecorder.delegate = self; [soundRecorder prepareToRecord]; [soundRecorder record]; recording = YES; I write for stop recording [soundRecorder stop]; recording = NO; self.soundRecorder = nil; I write for play AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: self.soundFileURL error: nil]; [fileURL release]; self.player = newPlayer; [newPlayer release]; [player prepareToPlay]; [player setDelegate: self]; [button setTitle : @"Pause"forState: UIControlStateHighlighted]; [button setTitle : @"Pause"forState: UIControlStateNormal]; [player play]; In iPhone Simulator all ok I record then stop then play and all work fine. But in my iPhone device no sound. Any help will be greatly apprecieated

    Read the article

  • how to play an audio soundclip when a nib is loaded - welcome screen - xcode

    - by Pavan
    I would like to do the following two things: 1) I would like to play an audio file qhen a nib is loaded 2) After that i would like to switch views when the audio file has finished playing. This will be easy as i just need to call the event that initiates the change of view by using the delegate method -(void) audioPlayerDidFinishPlaying{ //code to change view } I dont know how to to play the audio file when a nib is loaded. Using the AVFoundation framework, I tried doing the following after setting up the audio player and the variables associated with it in the appropriate places i wrote the following: - (void)viewDidLoad { [super viewDidLoad]; NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"sound" ofType: @"mp3"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error:nil]; [fileURL release]; self.player = newPlayer; [newPlayer release]; [player prepareToPlay]; [player setDelegate: self]; [player play]; } Although this does not play the file as the viewdidload method gets called before the nib is shown so the audio is never played or heard. What do i need to do so that i can play the audio file AFTER the nib has loaded and is shown on the screen? can someone please help me as ive been working on this for 3 hours now. Thanks in advance.

    Read the article

  • Sound Delay With AVAudio Player

    - by Will Youmans
    I'm using the following code in my viewDidLoad to load a sound: NSURL * url = [NSURL fileURLWithPath: [NSString stringWithFormat:@"%@/Moto - Hit Sound.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError * error; hitSoundPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error]; hitSoundPlayer.numberOfLoops = 0; Then I'm using this in a void method to play the sound: if(CGRectIntersectsRect(main.frame, enemy1.frame)){ [hitSoundPlayer play]; } This does seem to work, however the first time the sound is played there is a lot of lag and the game stops temporarily. I'm using this same method for when in an IBAction and it works fine, it must be the fact that it's also detecting a collision that makes the sound lag. If I want to be able to play sounds quickly and on the spot without any sort of lag am I doing the right thing? Do I want to use another method? I'm not using any frameworks like cocos2d. If you need to see any more code just ask.

    Read the article

  • off a sound effect with NSUserDefaults

    - by Momeks
    i try to off a sound effect on my app play method is [myMusic play]; ' BOOL soundIsOff = [defaults boolForKey:@"sound_off"]; //the problem is here //xcode compiler doesn't copile this code [myMusic play] = soundIsOff; sound code : ///sound effect ', NSString * musicSonati = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"]; myMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicSonati] error:NULL]; myMusic.delegate = self; myMusic.numberOfLoops = 0;

    Read the article

  • Objective-C: iPad Crash When Screen Shot Button Clicked

    - by SeongHo
    OK, i am making a Coloring app and it has a "Save" button that will take the screen shot of the view where the drawing is. I have 6 images to color. In the intro page there 6 buttons, each will link you to a particular coloring page. All are working well including the "Save" button except for one. All coloring views has the same contents and functions but in one image, it crashes the iPad whenever i clicked the "Save" button. Here's some of my codes: On Button Click: [self saveScreenshotToPhotosAlbum]; camFlash = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]; [camFlash setBackgroundColor:[UIColor whiteColor]]; [camFlash setAlpha:0.0]; [cbHolder addSubview:camFlash]; [cbHolder bringSubviewToFront:camFlash]; [UIView beginAnimations:@"Flash-On" context:NULL]; [UIView setAnimationDuration:0.2]; [UIView setAnimationRepeatAutoreverses:NO]; [camFlash setAlpha:1.0]; [UIView commitAnimations]; NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"flash" ofType:@"wav"]; AVAudioPlayer *flashSFX = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:NULL]; flashSFX.volume = 0.5; flashSFX.numberOfLoops = 0; self->camFlashSFX = flashSFX; if ([flashSFX currentTime] != 0) [flashSFX setCurrentTime:0]; [flashSFX play]; [self performSelector:@selector(removeFlash) withObject:nil afterDelay:0.2]; Remove Flash: - (void) removeFlash { [camFlash removeFromSuperview]; } For the screenshot: - (UIImage*)captureView { UIGraphicsBeginImageContext(CGSizeMake(1024, 768)); CGContextRef context = UIGraphicsGetCurrentContext(); [cbHolder.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } - (void)saveScreenshotToPhotosAlbum { UIImageWriteToSavedPhotosAlbum([self captureView], nil, nil, nil); } This one is for the button that will show the coloring page: uc4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tpUncolored1.png"]]; [uc4 setUserInteractionEnabled:YES]; [uc4 setFrame:CGRectMake(0, 0, 1024, 768)]; [cbHolder addSubview:uc4]; clrd4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tpColored1.png"]]; [clrd4 setUserInteractionEnabled:YES]; [clrd4 setFrame:CGRectMake(0, 0, 1024, 768)]; [cbHolder addSubview:clrd4]; [UIView beginAnimations:@"fabe-out" context:NULL]; [UIView setAnimationDuration:1.5]; [clrd4 setAlpha:0.0]; [UIView commitAnimations]; [self performSelector:@selector(cb4) withObject:nil afterDelay:1.5];

    Read the article

  • Play a wav file retrieved from a database on the iPhone?

    - by user312917
    I have alot of wav files stored in sqlite3, but when I retrieve one of them, I can't play it. The retrieve code is NSData *soundData = (NSDATA *)sqlite3_column_blob(statement, 0); mPlayer = [[AVAudioPlayer alloc] initWithData:soundData error:&error]; The data is stored as binary and it's there when I search for it using sqlite3.

    Read the article

  • Progressive download using Matt Gallagher's audio streamer

    - by Fernando Valente
    I'm a completely n00b when talking about audio. I'm using Matt Gallagher's audio streamer on my radio app. How may I use progressive download? Also, ExtAudioFile is a good idea too :) Edit: Used this: length = CFReadStreamRead(stream, bytes, kAQDefaultBufSize); if(!data) data =[[NSMutableData alloc] initWithLength:0]; [data appendData:[NSData dataWithBytes:bytes length:kAQDefaultBufSize]]; Now I can save the audio data using writeToFile:atomically: NSData method, but the audio won't play. Also, if I try to load it on a AVAudioPlayer, I get an error.

    Read the article

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