iphone - Playing two videos after another causes short black screen -


i have app play movie after touch on view , when movie finished. place button on view. on clicking button second movie plays. seems loaded , short black screen appears. want avoid black screen now...

heres code:

initialization in viewdidload

[super viewdidload]; // additional setup after loading view, typically nib.  nsstring *movpath = [[nsbundle mainbundle]                       pathforresource:@"movie1"                       oftype:@"m4v"];  mpviewcontroller =  [[mpmovieplayerviewcontroller alloc]  initwithcontenturl:[nsurl fileurlwithpath:movpath]];   [[nsnotificationcenter defaultcenter]  addobserver:self  selector:@selector(moviefinishedcallback:)                                                   name:mpmovieplayerplaybackdidfinishnotification  object:nil];   mp = [mpviewcontroller movieplayer]; // [mp setmoviecontrolmode:mpmoviecontrolmodehidden]; // [mp.view setframe:cgrectmake(0, 0, 250, 263)];  mp.controlstyle = mpmoviecontrolstylenone;     mp.shouldautoplay = no;  [mp preparetoplay]; [mp pause]; 

then on storyboard touch call startanimation

- (ibaction)startanimation:(id)sender {       nslog(@"animation 1");       [self.view addsubview:mpviewcontroller.view];     [mp play]; } 

after movie finishes set button

- (void) moviefinishedcallback:(nsnotification*) anotification {    nslog(@"...movie done");  // generate start button animation 2 startanimation2button = [uibutton buttonwithtype:uibuttontyperoundedrect]; startanimation2button.tag = 1; [startanimation2button addtarget:self action:@selector(startanimation2:) forcontrolevents:uicontroleventtouchupinside]; startanimation2button.frame = cgrectmake(130, 230, 070, 070); startanimation2button.userinteractionenabled = yes; startanimation2button.alpha = 0.1;  [self.view addsubview:startanimation2button]; } 

then after touch on button, second animation starts

- (ibaction)startanimation2:(id)sender  {      nslog(@"animation 2");     nsstring *movpath = [[nsbundle mainbundle]                       pathforresource:@"movie2"                       oftype:@"m4v"];     [mp setcontenturl:[nsurl fileurlwithpath:movpath]];      [[nsnotificationcenter defaultcenter]          addobserver:self          selector:@selector(moviefinishedcallback2:)                                                           name:mpmovieplayerplaybackdidfinishnotification          object:nil];      [mp play]; } 

but here short black screen appears, while movie2 loaded , playing.

how can avoid black screen?

greetz

you not able entirely rid of pre buffering delay (black phase) between videos when using mpmovieplayercontroller.

use avqueueplayer instead.

avqueueplayer subclass of avplayer use play number of items in sequence.

see other questions , issues on matter.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -