The mpmovieplayercontroller class is a very powerful class that can play mov, MP4, MPV, m4v, 3GP, MP3, AIFF, and m4a. It is also very simple to define. The following describes the simple usage of mpmovieplayercontroller and the problems I encountered during use.
I am using sdk4.1. Now there should be no hardcore developers still using sdk3.
Mpmovieplayercontroller * movieplayer; movieplayer = [[mpmovieplayercontroller alloc] initwithcontenturl: URL of the file to be played]; movieplayer. scalingmode = mpmoviescalingmodeaspectfill; [movieplayer. views setframe: cgrectmake (30,210,250,350)]; [movieplayer. view setbackgroundcolor: [uicolor clearcolor]; [self. view addsubview: movieplayer. view]; [movieplayer play];
Note:
1. The scalingmode attribute determines the filling mode of the added video player.
2. You must call the setframe method of movieplayer. View. Otherwise, the player you added will play only the sound without an image.
3. After setting various attributes of movieplayer, do not call the addsubview method of the current view to add movieplayer. view as the subview of the current view.
4. If the file to be played is an audio file rather than a video file, there is only one playing column during playback.