Playing videos on iPad with a specific style
i have some mp4 files which are to be played in my iPad app.. I am able to do that quite well. right now i have a play button on blank black space in my app and the video plays after i tap the play button. The user will only come to know the content of the video after playing it.. But, i want the user to know about the video before playing itself . instead of the default black screen i want to show the video starting screen to make the video more interesting. To put it in simple words, i w开发者_C百科ant my video space to be similar to youtube... IS there any way i which this can be done?? Thanks
Subclass MPMoviePlayerController
(or however you're playing your video.. if you already use a custom class just add the code in there) and in viewDidAppear
initialise a UIImageView
with frame size equal to self.view.bounds
using whatever background image you want for the loading screen. Add the UIImageView
as a subview of self.view
and call sendSubviewToBack:
on it. When the player is ready to play, it will start drawing video frames on top of your subview, and you should not see it again.
- (void)viewDidAppear
{
UIImageView *loadingImage = [[UIImageView alloc] initWithImage:myImage];
[loadingImage setFrame:self.view.bounds];
[self.view addSubview:loadingImage];
[self.view sendSubviewToBack:loadingImage];
[super viewDidAppear];
}
精彩评论