IPhone development Note (1) MPMoviePlayerController usage and solution for playing audio without images

Source: Internet
Author: User

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.


[C-sharp]
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. Www.2cto.com

4. If the file to be played is an audio file rather than a video file, there is only one playing column during playback.

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.