"iOS development" resolves "a black screen splash screen issue when clicking MPMoviePlayerController to play Video"

Source: Internet
Author: User

When you click on a button to play the video, if the button triggers the function when the Alloc MPMoviePlayerController object, loading the resource file, because loading the resource file also takes time, there will be a short black splash screen, this experience is very bad, there is a good solution is, Pre-Alloc the MoviePlayer object in advance and call play directly when the button is clicked.


Pre-load related code:

Pre-load video to avoid black screen    nsstring *videopath=[[nsbundle mainbundle]pathforresource:@ "Startvideo" oftype:@ "mp4"];    Self.moviecontroller=[[mpmovieplayercontroller alloc] Initwithcontenturl:[nsurl Fileurlwithpath:videopath]];    [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (moviefinish:) Name: Mpmovieplayerplaybackdidfinishnotification Object:self.movieController];    Self.moviecontroller.scalingmode=mpmoviescalingmodeaspectfill;    [Self.view InsertSubview:movieController.view Belowsubview:bgimgview];    Self.moviecontroller.view.frame=cgrectmake (0,0, 1024x768, 768);    [Self.moviecontroller Setcontrolstyle:mpmoviecontrolstylenone];      Remove the progress bar    self.movieController.initialPlaybackTime = -1.0;    [Self.moviecontroller Setshouldautoplay:no];    [Self.moviecontroller Preparetoplay];

Note in particular:

[self. Moviecontroller setshouldautoplay:NO];

[self. Moviecontrollerpreparetoplay];

Set AutoPlay to No, the default is yes, it will play automatically.

"iOS development" resolves "a black screen splash screen issue when clicking MPMoviePlayerController to play Video"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.