xcode - Refresh and set new item AVPlayer class -


i'm trying refresh nsview in video finishes playing. i'd after click button next or previous refresh view in video played. see new view overlapping old vindow. i've tried using removefromsuperview removes nsvindow. how solve this?

my code:

@interface appdelegate () {     avplayer *player; }  @property (weak) iboutlet nswindow *window; @end    @implementation appdelegate  @synthesize playerview;  - (void)applicationdidfinishlaunching:(nsnotification *)anotification {       nsurl *url = [[nsbundle mainbundle] urlforresource:@"pieniadz" withextension:@"3gp"];     player = [avplayer playerwithurl:url];       avplayerlayer *playerlayer = [avplayerlayer playerlayerwithplayer:player];     [self.playerview.layer addsublayer:playerlayer];     playerlayer.frame = self.playerview.layer.bounds;     playerlayer.autoresizingmask = kcalayerwidthsizable | kcalayerheightsizable;     player.actionatitemend = avplayeractionatitemendnone;     // [player play];      // insert code here initialize application }  - (void)applicationwillterminate:(nsnotification *)anotification {     // insert code here tear down application } - (ibaction)play:(id)sender {     [player play];  }  - (ibaction)stop:(id)sender {     [player pause];  } - (ibaction)previous:(id)sender {     [player pause];     [self.playerview removefromsuperview];     nsurl *url = [[nsbundle mainbundle] urlforresource:@"pieniadz" withextension:@"3gp"];     player = [avplayer playerwithurl:url];     [self.playerview.layer removeallanimations];     //[self.playerview setneedsdisplay:yes];     //[self.playerview.layer removeallanimations];     avplayerlayer *playerlayer = [avplayerlayer playerlayerwithplayer:player];     [self.playerview.layer addsublayer:playerlayer];      // [self.playerview.layer setneedsdisplay];     playerlayer.frame = self.playerview.layer.bounds;     playerlayer.autoresizingmask = kcalayerwidthsizable | kcalayerheightsizable;     player.actionatitemend = avplayeractionatitemendnone; }   - (ibaction)next:(id)sender {     [player pause];     nsurl *url = [[nsbundle mainbundle] urlforresource:@"fatality" withextension:@"mp4"];     [self.playerview setsubviews:[nsarray array]];     player = [avplayer playerwithurl:url];     //[self.playerview setneedsdisplay:yes];     [self.playerview.layer removeallanimations];         avplayerlayer *playerlayer = [avplayerlayer playerlayerwithplayer:player];     [self.playerview.layer addsublayer:playerlayer];     // [self.playerview.layer setneedsdisplay];         playerlayer.frame = self.playerview.layer.bounds;         playerlayer.autoresizingmask = kcalayerwidthsizable | kcalayerheightsizable;     player.actionatitemend = avplayeractionatitemendnone;  } @end 

when first create playerlayer, save in mvar (member variable). let suppose called _myplayerlayer. in next: , previous: methods, this:

[_myplayer removefromsuperlayer]; 

and create new instance of player layer, assign _myplayer, , add sublayer of view's layer did before.

notice code not affect view @ all.

i don't know why calling setsubviews: - line looks wrong.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -