Audio/Video Processing

Source: Internet
Author: User

1> audio playback

Ø dependent frameworks: avfoundation and audiotoolbox ø play long Music: avaudioplayer ø play short sound: load the audio file to generate systemsoundid ø recording: avaudiorecord

 

2> video playback

Differences between the two video playback classes:

Mpmovieplayercontroller inherits from nsobject;

Mpmovieplayerviewcontroller inherits from uiviewcontroller, which encapsulates an mpmovieplayercontroller. Easy to use:
// Load the video resource nsstring * urlstring = [[nsbundle mainbundle] pathforresource: @ "sample_itunes" oftype: @ "mov"]; nsurl * url = [nsurl fileurlwithpath: urlstring]; // create a player _ player = [[mpmovieplayercontroller alloc] initwithcontenturl: url]; // set the size of _ player. view. frame = self. view. bounds; _ player. view. autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; // Add it to the Controller view [self. view addsubview: _ player. view]; // play [_ player play];
// Listen for changes in the playback status [[nsnotificationcenter defacenter center] addobserver: Self selector: @ selector (videostatechange)
Name: mpmovieplayerplaybackstatedidchangenotification object: _ Player]; // listen to the player end full screen [[nsicationicationcenter defacenter center] addobserver: Self selector: @ selector (exitfullscreen)
Name: mpmovieplayerdidexitfullscreennotification object: _ Player];

Other attributes and methods:

Whether to automatically play @ property (nonatomic) bool shouldautoplay; full screen display @ property (nonatomic, Getter = isfullscreen) bool fullscreen;-(void) setfullscreen :( bool) fullscreen animated :( bool) animated; capture the image in the video-(void) requestthumbnailimagesattimes :( nsarray *) playbacktimes timeoption :( mpmovietimeoption) option;

Complete code: Video Playback

Appendix:

1> Add images to the system album

Uiimagewritetosavedphotosalbum ([uiimage imagenamed: @ "default.png"], self, @ selector (image: didfinishsavingwitherror: contextinfo :), null );

2> uisavevideoatpathtosavedphotosalbum Function

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.