The use of MPMoviePlayerController class video playback in the iOS Dev-97 MediaPlayer framework and Runtime runtime

Source: Internet
Author: User

(1) Using media playback, you need to load the <MediaPlayer/MediaPlayer.h> frame first, and #import import. Several points to note about media playback are:

-Full screen settings need to be set after the view is visible to be valid.

--all kinds of control is realized by notification Nsnotificationcenter, there is a full screen to enter/exit, play pause state change and so on.

#import "WPMoviePlayController.h" #import <MediaPlayer/MediaPlayer.h> @interface Wpmovieplaycontroller () @ Property (Nonatomic,strong) MPMoviePlayerController *movie; @end @implementation wpmovieplaycontroller-( MPMoviePlayerController *) movie{if (_movie==nil) {//Get file path directly to URL, success Nsurl *url=[[nsbundle Mainbundle]ur        lforresource:@ "A.mp4" withextension:nil];        _movie=[[mpmovieplayercontroller Alloc]initwithcontenturl:url];        _movie.view.frame=self.view.bounds;    [Self.view Addsubview:_movie.view]; } return _movie;}    -(void) viewdidload{[Super Viewdidload];    [Self.movie play]; [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (enterfullscreen) Name:    Mpmovieplayerdidenterfullscreennotification Object:nil]; [[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (exitfullscreen) Name: Mpmovieplayerdidexitfullscreennotification Object:nil];} -(void) Viewdidappear: (BOOL) animated{//setting This property to YES BEfore the movie player ' s view is visible would have no effect. This property needs to be set only after the movie player object view is rendered, the light load does not work, it needs to wait for the appear after setting, so use Self.movie.fullscreen=yes in this method;} -(void) enterfullscreen{NSLog (@ "Go full Screen");}    -(void) exitfullscreen{[Self.movie stop];    [Self dismissviewcontrolleranimated:yes completion:nil]; NSLog (@ "exit full screen");}

(2) What is the runtime?

--That's all the things that each method/function calls between each other.

--In most cases, the runtime runs silently behind the scenes, and it is primarily used to write and compile OC source programs

--using clang to compile the OC source program (such as MAIN.M) into the CPP code, so that you can see the underlying runtime implementation of the principle, is to understand the principle of OC underlying one of the methods.

CLANG-REWRITE-OBJC main.m

A main.cpp file is generated, and then

Open main.cpp

can be viewed.

Interview: Did you use runtime development?

Answer: Runtime is the method call between those things, is to do the bottom, I sometimes use clang to decompile the source code into C + +, nothing to see the underlying implementation principle.

The use of MPMoviePlayerController class video playback in the iOS Dev-97 MediaPlayer framework and Runtime runtime

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.