Audio and video

Source: Internet
Author: User

1. System albums and photos

Multimedia parameters with System presets
#import <MobileCoreServices/MobileCoreServices.h>

Uiimagepickercontroller photos and get system albums
Determine if support
BOOL ret = [Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera];

Uiimagepickercontroller *imagepicker = [[Uiimagepickercontroller alloc] init];
Set Resource type
imagepicker.sourcetype = type;
Set up Proxy
imagepicker.delegate = self;
Allow subsequent processing of albums, etc.
imagepicker.allowsediting = YES;
[Self presentviewcontroller:imagepicker animated:yes completion:^{

}];


#pragma mark-uiimagepickercontrollerdelegate
When you click the Cancel button on the picker, the method that is triggered
-(void) Imagepickercontrollerdidcancel: (Uiimagepickercontroller *) picker{
NSLog (@ "cancel!!");
Realizing the dismiss of picker
[Picker Dismissviewcontrolleranimated:yes completion:^{
}];
}


Click the Choose button to trigger the method
Info with selected resources
-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info {

Determine the type of selected resource
NSString *mediatype = [info objectforkey:uiimagepickercontrollermediatype];
Kuttypeimage System preset Picture resource type
if ([MediaType isequaltostring: (NSString *) Kuttypeimage]) {
The proof was taken out of the picture
Get a selected picture from a dictionary
UIImage *image = [info objectforkey:uiimagepickercontrollereditedimage];
The picture taken from the camera occupies space: (1m-2m) around, you need to compress the picture, and then in the subsequent operation
Compress the original image into a 50*50 size
UIImage *smallimage = [[Imagetool Sharetool] Resizeimagetosize:cgsizemake (50,50) sizeofimage:image];
Self.view.backgroundColor = [Uicolor colorwithpatternimage:smallimage];
}
[Picker Dismissviewcontrolleranimated:yes completion:^{
}];
}


2.Video
Mpmovieplayerviewcontroller
@ "Http://hot.vrs.sohu.com/ipad1407291_4596271359934_4618512.m3u8"

Create a controller with a video player
_Playcontroller = [[Mpmovieplayerviewcontroller alloc] initwithcontenturl:url];
_playcontroller.movieplayer.moviesourcetype = Mpmoviesourcetypefile;
Presented in a modal way
[Self Presentviewcontroller:_playcontroller animated:yes completion:^{

}];


3. Audio
Avaudioplayer protocol method

#pragma mark-avaudioplayerdelegate
When successful playback completes a songs, call this method
-(void) audioplayerdidfinishplaying: (Avaudioplayer *) player successfully: (BOOL) flag{
NSLog (@ "Play end");
}

Audio and video

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.