Sunday, 15 August 2010

ios - Exception with playing audio file by using MPMoviePlayerController -



ios - Exception with playing audio file by using MPMoviePlayerController -

i used mpmovieplayercontroller play autio in local or url. when first play information,i should download file , play @ same time.then sec time ,i can play info local if existed.

now create singleton named playcontroller command autoplay,play ,pause,stop manually. if take picture,it autoplay file consistent picture.if can not playstatus,user should play yourself.i can clicked different image play right audio.

the problem met when clickked different picture,sometimes bug jump uploaded screenshot.

init singleton:

-(playcontroller*)initwithscenicspot:(scenicspot*)sp { pauseimg=[uiimage imagenamed:@"readyplay.png"]; playimg=[uiimage imagenamed:@"readypause.png"]; if (![currentscenicspot.scenicspotid isequaltostring:sp.scenicspotid]) { currentscenicspot=[sp retain]; self=[super init]; if (self) { if(!pcontroller){ pcontroller = [[mpmovieplayercontroller alloc] init]; } [nstimer scheduledtimerwithtimeinterval:1.0f target:self selector:@selector(loginfo) userinfo:nil repeats:yes]; [self.view setbackgroundcolor:[uicolor bluecolor]]; detailview=[[detailview alloc]initwithframe:[[uiscreen mainscreen] bounds]]; detailview._clickbutton=self; [self.view addsubview:detailview]; self.view.frame=[[uiscreen mainscreen] bounds]; nsurl* ns = nil /*=[helptools returnspotaudioserverpath:sp.scenicspotid]*/; nsstring *audiodiskpath = [helptools returnspotaudiodiskpath:sp.scenicspotid]; nsstring *audioserverpath = [helptools returnspotaudioserverpath:sp.scenicspotid]; // nsurl* ns = nil; bool isnet = no; if ([helptools isfileexist:audiodiskpath]) { ns = [nsurl fileurlwithpath:audiodiskpath]; } else{ ns = [nsurl urlwithstring: audioserverpath]; [self downloadaudio:sp.scenicspotid]; isnet = yes; } [self setcontenturl:ns isnet:isnet];

set sound path

-(void)setcontenturl:(nsurl*)url isnet:(bool)isnetdata { if (isnetdata) { if ([pcontroller respondstoselector:@selector(loadstate)]) { [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(handleplayback:) name:mpmovieplayerloadstatedidchangenotification object:nil]; [pcontroller setcontenturl:url]; [detailview.coloredplaybar setprogress:0 animated:no]; [pcontroller preparetoplay]; } else { [detailview.coloredplaybar setprogress:0 animated:no]; [pcontroller play]; } } else { [detailview.coloredplaybar setprogress:0 animated:no]; if (pcontroller.playbackstate){ [pcontroller play]; } }

update playstatus

-(void)loginfo { if (pcontroller.playbackstate) { float playprocess=(float)pcontroller.currentplaybacktime/(float)pcontroller.duration; [detailview.coloredplaybar setprogress:playprocess]; if (pcontroller.playbackstate==mpmovieplaybackstatestopped|| pcontroller.playbackstate==mpmovieplaybackstatepaused) { [detailview.playcontrollbutton setimage:playimg forstate:uicontrolstatenormal]; } else { [detailview.playcontrollbutton setimage:pauseimg forstate:uicontrolstatenormal]; } } else { [detailview.playcontrollbutton setimage:playimg forstate:uicontrolstatenormal]; } } - (void)handleplayback:(nsnotification *)notif { mpmovieplayercontroller *themovie = (mpmovieplayercontroller*)[notif object]; if ([themovie loadstate] != mpmovieloadstateunknown) { [[nsnotificationcenter defaultcenter] removeobserver:self name:mpmovieplayerloadstatedidchangenotification object:nil]; if ([playcontroller getplayer].loadstate == mpmovieloadstateplaythroughok) { if (pcontroller.playbackstate && pcontroller.playbackstate == mpmovieplaybackstateplaying) { [pcontroller play]; } } } }

debug

com.apple.coremedia.player.async:exc_bad_access(code = 1,address = 0x4)

crash file

incident identifier: 3cf84469-2c6a-42f8-8db7-490a8bcb7fce crashreporter key: 3bb7c18d7a7efc7433f20023298207ebb260efd2 hardware model: iphone3,1 process: horticulturaljinzhou [1761] path: /var/mobile/applications/6a4ba4e5-ddf6-4cf5-a9dc-685c2fe4b799/horticulturaljinzhou.app/horticulturaljinzhou identifier: horticulturaljinzhou version: ??? (???) code type: arm (native) parent process: launchd [1] date/time: 2013-01-24 12:27:37.314 +0800 os version: iphone os 5.0.1 (9a405) study version: 104 exception type: exc_bad_access (sigsegv) exception codes: kern_invalid_address @ 0x00000004 crashed thread: 10 ![enter image description here][1]![enter image description here][2]![enter image description here][3]![enter image description here][4] ![enter image description here][5]![enter image description here][6] thread 10 name: com.apple.coremedia.player.async thread 10 crashed: 0 webcore 0x3654b098 webcore::timerbase::setnextfiretime(double) + 116 1 webcore 0x36590862 webcore::frameview::layout(bool) + 106 2 webcore 0x365a8d32 webcore::frameview::updatelayoutandstyleifneededrecursive() + 86 3 webkit 0x34e5e898 -[webhtmlview(webinternal) _web_updatelayoutandstyleifneededrecursive] + 36 4 webkit 0x34e5e79a -[webhtmlview(webprivate) viewwilldraw] + 74 5 corefoundation 0x341157fc -[nsobject performselector:] + 32 6 corefoundation 0x3411648a -[nsarray makeobjectsperformselector:] + 146 7 corefoundation 0x341157fc -[nsobject performselector:] + 32 8 corefoundation 0x3411648a -[nsarray makeobjectsperformselector:] + 146 9 corefoundation 0x341157fc -[nsobject performselector:] + 32 10 corefoundation 0x3411648a -[nsarray makeobjectsperformselector:] + 146 11 corefoundation 0x341157fc -[nsobject performselector:] + 32 12 corefoundation 0x3411648a -[nsarray makeobjectsperformselector:] + 146 13 webkit 0x34e5e746 -[webview(webprivate) viewwilldraw] + 86 14 webcore 0x365a8a6a webcore::tilecache::preparetodraw() + 46 15 webcore 0x36c05270 -[tilelayer layoutsublayers] + 36 16 quartzcore 0x34ca5f92 ca::layer::layout_if_needed(ca::transaction*) + 210 17 quartzcore 0x34caa114 ca::context::commit_transaction(ca::transaction*) + 220 18 quartzcore 0x34ca9e50 ca::transaction::commit() + 308 19 quartzcore 0x34ca9784 ca::transaction::pop() + 120 20 quartzcore 0x34ca9704 +[catransaction commit] + 28 21 mediatoolbox 0x34f30bf0 playerremote_addtoplayqueue + 356 22 mediatoolbox 0x34f1c540 playerasync_grabandrunonecommand + 808 23 mediatoolbox 0x34f1bfd2 fpa_asyncmoviecontrolthread + 42 24 coremedia 0x320d7bc6 figthreadmain + 146 25 libsystem_c.dylib 0x32f5cc16 _pthread_start + 314 26 libsystem_c.dylib 0x32f5cad0 thread_start + 0

ios

No comments:

Post a Comment