change background color of video iPad/iPhone
with the following method I play a video: (using the #import framework)
MPMoviePlayerController *player;
-(IBAction) playMovie: (NSS开发者_运维技巧tring*) videoName ViedeoType:(NSString*) videoType{
ViewVideoSubview.alpha = 0;
NSString *url = [[NSBundle mainBundle]
pathForResource:videoName
ofType:videoType];
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[ViewVideoSubview addSubview:player.view];
....
....
}
and the video plays fine. I am wondering if it possible to change the background color of the video from black to white?
the video plays in the black rectangle:
I have tried stuff like player.backgroundView.alpha = 0;
but that has not worked.
EDIT :
I have also tried:
[[player backgroundView] setBackgroundColor:[UIColor whiteColor]];
and that changes the background color but the area between the video and the player.view
Your question is a bit ambiguous, hence I am uncertain if my answer matches...
To change the color of the video-view that is showing as long as the movie is not yet fully loaded/playing:
player.view.backgroundColor = [UIColor whiteColor];
Note: It is not possible to change part of the encoded video data without reencoding the video itself.
moviePlayerViewController.view.backgroundColor = [UIColor blackColor]
UPD: the only thing that I can recommend is switching to low level AV Foundation. You will be able to control all the layers you need.
you can change the background color, after adding the playerController into the current view hierarchy insert the code below:
NSArray *subViews = [[[self playerController] view] subviews];
for(UIView *v in subViews)
{
if([v respondsToSelector:@selector(setBackgroundColor:)])
{
[v setBackgroundColor:[UIColor whiteColor]];
}
}
精彩评论