Objective C - MPMoviePlayerController cuts out -


so im trying play movie this:

- (void)viewdidload {     [super viewdidload];      vidlocation=[[nsurl alloc] initwithstring:@"http://cdn.webwaterfalls.com/uni/intronew2.mp4"];      uiview * vidview=[[uiview alloc] initwithframe:cgrectmake(10, 10, 300, 300)];      [self.view addsubview:vidview];      mpmovieplayercontroller * vid=[[mpmovieplayercontroller alloc] initwithcontenturl:vidlocation];      if(vid){          [vid setcontenturl:vidlocation];          [vid setmoviesourcetype:mpmoviesourcetypestreaming];          [vid.view setframe: vidview.bounds];          [vidview addsubview:vid.view];          [vid play];      } } 

and movie starts playing, displaying pause, seek to, volume , full screen controls.

but after 3 seconds movie cuts out, showing nothing. no movie. no controls.

ive tried different movies (all of play on ipad fine), give playing after 3 seconds.

can explain doing wrong?

try this:

- (void)viewdidappear:(bool)animated {    [super viewdidappear:animated];     //use apple's sample stream    nsurl *mediaurl = [nsurl urlwithstring:@"http://cdn.webwaterfalls.com/uni/intronew2.mp4"];    self.movieplayer = [[mpmovieplayercontroller alloc] initwithcontenturl:mediaurl];     //begin observing movieplayer's load state.    [[nsnotificationcenter defaultcenter] addobserver:self                                          selector:@selector(movieplayerloadstatechanged:)                                              name:mpmovieplayerloadstatedidchangenotification                                            object:self.movieplayer];     [self.movieplayer setshouldautoplay:no];//stop autoplaying    [self.movieplayer preparetoplay];//start preparing video }  - (void)movieplayerloadstatechanged:(nsnotification *)notification{     nslog(@"state changed to: %d\n", self.movieplayer.loadstate);     if(self.movieplayer.loadstate == mpmovieloadstateplayable){        //if load state ready play       [self.view addsubview:[self.movieplayer view]];       [self.movieplayer setfullscreen:yes];       [self.movieplayer play];//play video     }  } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -