ios - Playing audio with AVAudio Record from SQLite BLOB -


i have uibutton inside of uitableviewcell hooked method play avaudio file this:

cell.playbutton = [uibutton buttonwithtype:uibuttontyperoundedrect]; cell.playbutton.tag = indexpath.row; [cell.playbutton addtarget:self action:@selector(useselectedfile:) forcontrolevents:uicontroleventtouchupinside]; 

and useselectedfile method looks this:

-(void) useselectedfile:(id)sender{      int tag = [(uibutton *)sender tag];     nsdictionary *audiofileinformation = [audiocellsarray objectatindex:tag];     nsdata *selectedaudiofile = [audiofileinformation objectforkey:@"data"];     nserror *error;      nsstring *filepath = [[nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0] stringbyappendingpathcomponent:@"sound.caf"];     [[nsfilemanager defaultmanager] removeitematpath:filepath error:nil];     [selectedaudiofile writetofile:filepath atomically:yes];     nsurl *file = [nsurl fileurlwithpath:filepath];        _audioplayerforbutton = [[avaudioplayer alloc] initwithcontentsofurl:file error:&error];     if (error)         nslog(@"error: %@",               [error localizeddescription]);     else         [_audioplayerforbutton play];  } 

i can record files , save them in database , pull data out fine, can't play them. current code get: error: operation couldn’t completed. (osstatus error 1954115647.)

and when tried using:

_audioplayerforbutton = [[avaudioplayer alloc] initwithdata:selectedaudiofile error:&error]; 

i error when hitting play button: error: operation couldn’t completed. (osstatus error 2003334207.)

inspecting file write disk simulator seems corrupt maybe? file system doesn't show audio file normal .caf files (black music note) little white file quicktime symbol on quicktime won't play.

i tried using macerror statuscode on command line returns "unknown error".

anyone have ideas or tips on how resolve , files playing?

it turned out right, after comparing files more see data different changed storing files blob text , encoded them using base64 class here: iphone sdk base64 encode / decode


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -