The user is selecting different videos and the view is already loaded.
Post
Replies
Boosts
Views
Activity
The behavior is different with the two lines. The one with self works; the other doesn't. Based on the answers, it is because myImage is an IBOutlet.
Yes, I was commenting on your side comment, which was not the original question. My question about the screen sizing is that "frame" was not an option with [UIScreen mainScreen], yet I would think that I would use "frame" instead of "bounds".
You are right. The currentMode was giving me twice the resolution. Using width = [UIScreen mainScreen].bounds.size.width; height = [UIScreen mainScreen].bounds.size.height;gave me the correct width and height of the screen. I do not understand why "bounds" is the only option to get the size. I would have thought "frame" would be correct.
I seemed to get a good part working by adding the line of code:self.myImage.frame = self.view.frame;just above the [playerLayer addSublayer:playerLayer] lineWhat I don't understand is why it worked for the iPhone without this but not the iPad.
This worked.
Claude, it seems I am having trouble adding the button to my avplayer. The button never shows when I use avMovie.view or self.view when I try to add the subView. Any suggestions?-(void)playMovie: (NSString *) fileName{ NSLog(@"in playMovie second"); NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: fileName ofType:@"mp4"]]; AVPlayer *player = [AVPlayer playerWithURL:url]; AVPlayerViewController *avMovie = [[AVPlayerViewController alloc]init]; //AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; avMovie.view.frame = self.view.bounds; avMovie.player = player; //playerLayer.frame = self.view.bounds; //[playerLayer setVideoGravity:AVLayerVideoGravityResizeAspect]; //[self.view.layer addSublayer:playerLayer]; [player play]; //make button UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(30,30,100,60); [button setTitle:@"Done" forState:UIControlStateNormal]; [button addTarget:self action:@selector(myDoneButtonMethod:) forControlEvents:UIControlEventTouchUpInside]; [avMovie.view addSubview:button]; //show view controller [self addChildViewController:avMovie]; [self.view addSubview:avMovie.view]; //avMovie.view.frame = self.view.frame; //[player replaceCurrentItemWithPlayerItem:nil]; //[player pause]; //[avMovie.view removeFromSuperview]; }
I do appreciate you getting back to me.
I used[avMovie.view removeFromSuperview];to remove the view. However, the player does not have a "Back/done" button. Do I have to manually code one in or is there a title or subtitle feature that allows me to enter this functionality?
I realize how confusing my question sounds. I need to rethink this and find what code I can present.