Playing youtube video using HCYoutubeParser - ios

I am using HCYoutubeParser(https://github.com/hellozimi/HCYoutubeParser) to play some videos in my ios app. When I am trying to play some video, it doesn't seem to play it.
The code looks like this:
- (void)playVideo:(id)sender
{
if (_urlToLoad)
{
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc]initWithContentURL:_urlToLoad];
_mp = player;
[self presentViewController:_mp animated:YES completion:nil];
}
}
- (void)submitYouTubeURL:(id)sender {
[playButton setImage:nil forState:UIControlStateNormal];
NSURL *url = [NSURL URLWithString:_urlOfYoutube];
activityIndicator.hidden = NO;
[HCYoutubeParser thumbnailForYoutubeURL:url thumbnailSize:YouTubeThumbnailDefaultHighQuality completeBlock:^(UIImage *image, NSError *error) {
if (!error) {
[playButton setBackgroundImage:image forState:UIControlStateNormal];
playButton.hidden = NO;
NSDictionary *qualities = [HCYoutubeParser h264videosWithYoutubeURL:url];
_urlToLoad = nil;
_urlToLoad = [NSURL URLWithString:[qualities objectForKey:#"medium"]];
NSLog(#"%#",[NSURL URLWithString:[qualities objectForKey:#"medium"]]);
activityIndicator.hidden = YES;
[playButton setImage:[UIImage imageNamed:#"play_button"] forState:UIControlStateNormal];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:#"Dismiss" otherButtonTitles:nil];
[alert show];
}
}];
}
The line that gives the problem is _urlToLoad = [NSURL URLWithString:[qualities objectForKey:#"medium"]];
[NSURL URLWithString:[qualities objectForKey:#"medium"]] returns null..
How do I solve this?

In my case , I was getting 0 key value pair for
NSDictionary *qualities = [HCYoutubeParser h264videosWithYoutubeURL:url];
Ie , I was getting qualities having 0 key value pair.
I found that code in HCYoutubeParser.m , in method + (NSDictionary *)h264videosWithYoutubeID:(NSString *)youtubeID a variable signature variable was not getting initialized , so I replaced NSString *signature = nil; with NSString *signature = #"";

Related

When i post image to instagram from my app it directly opens to filter section of Instagram but i want it to open cropping section of Instagram?

- (IBAction)postToInstagram:(id)sender {
NSURL *instagramURL = [NSURL URLWithString:#"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
CGRect rect = CGRectMake(0,0,0,0);
NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:#"Documents/Home_1_instgram.igo"];
UIImage *imageN = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:#"%#", jpgPath]];
// [UIImagePNGRepresentation(_imageDetail.image) writeToFile:jpgPath atomically:YES];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#",jpgPath]];
self.documentController.UTI = #"com.instagram.exclusivegram";
self.documentController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
NSString *caption = self.catalogueImage.caption; //settext as Default Caption
//Removing pre-filled captions from mobile sharing
//http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing
self.documentController.annotation = [NSDictionary dictionaryWithObject:#"Here Give what you want to share" forKey:#"InstagramCaption"];
NSLog(#"caption: %#",caption);
[self.documentController presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
}
else
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:#"INSTAGRAM NOT FOUND" message:#"Please install instagram to post to instagram." delegate:nil cancelButtonTitle:nil otherButtonTitles:#"ok", nil];
[alert show];
}
}
I found the solution to it. In iOS Instagram directly sends user to the filter section whereas in android the user is directed to the crop section. It was mentioned in Instagram iPhone Hook.
Thank You
i have changed something in your code :
you should use com.instagram.photo
- (IBAction)postToInstagram:(id)sender {
if ([self schemeAvailable:#"instagram://app"])
{
CGRect rect = CGRectMake(0,0,0,0);
NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:#"Documents/Home_1_instgram.igo"];
UIImage *imageN = [UIImage imageNamed:#"IMG_1304.PNG"];
[UIImagePNGRepresentation(imageN) writeToFile:jpgPath atomically:YES];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#",jpgPath]];
self.documentController.UTI = #"com.instagram.photo";
self.documentController = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
NSString *caption = #"YourCaption"; //settext as Default Caption
//Removing pre-filled captions from mobile sharing
//http://developers.instagram.com/post/125972775561/removing-pre-filled-captions-from-mobile-sharing
self.documentController.annotation = [NSDictionary dictionaryWithObject:#"Here Give what you want to share" forKey:#"InstagramCaption"];
NSLog(#"caption: %#",caption);
[self.documentController presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
}
else
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:#"INSTAGRAM NOT FOUND" message:#"Please install instagram to post to instagram." delegate:nil cancelButtonTitle:nil otherButtonTitles:#"ok", nil];
[alert show];
}
}

HMAccessoryDelegates not calling on Button action

I am working on Homekit iOS app. I have a question that I have an accessory and When I change its power characteristic value using the HomeKit Simulator the delegates of HMAccessory are caliing but in case If I change the powr characteristic value programmatically (Using the writevalue ) the delegate methods are not being called. Please let me know any ideas of suggestions.
Code
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
selectedDevice.delegate = self;
}
HMAccessoryDelegate
- (void)accessory:(HMAccessory *)accessory service:(HMService *)service didUpdateValueForCharacteristic:(HMCharacteristic *)characteristic;
{
NSLog(#"changed");
}
Write Function
UISwitch *sw = [[UISwitch alloc] initWithFrame:CGRectMake(230, 5, 51, 31)];
[cell addSubview:sw];
sw.on = YES;
[sw addTarget:self action:#selector(updateState:) forControlEvents:UIControlEventValueChanged];
-(void)updateState:(UISwitch*)sender
{
HMCharacteristic *characteristic = self.selectedService.characteristics[tag];
[characteristic enableNotification:YES completionHandler:^(NSError *error)
{
if(!error)
{
}
}];
if([characteristic.characteristicType isEqualToString:HMCharacteristicTypePowerState])
{
id val = characteristic.value;
NSString *str = [NSString stringWithFormat:#"%#",val];
if([str isEqualToString:#"0"])
{
id a = characteristic.value;
BOOL b = [a boolValue];
NSNumber *c = [NSNumber numberWithBool:!b];
AppDelegate *appDel = [[UIApplication sharedApplication] delegate];
[characteristic writeValue:c completionHandler:^(NSError *error) {
if (error) {
UIAlertView *alertController = [[UIAlertView alloc] initWithTitle:#"Error" message:[appDel handleErrorCodes:error.code] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alertController show];
return;
}
else
{
[serviceCharacteristicsTableView reloadData];
}
}];
}
}
Please let me know if I am not clear
The documentation says that the delegate method is not called when you set the value programatically:
This method is called as a result of a change in value initiated by
the accessory. Programmatic changes initiated by the app do not result
in this method being called.
If you want to do something after writing the characteristic's value succeeded (or failed), you can do it in the completionHandler: block of writeValue:completionHandler: method.

XCode UIActionSheet image

I am creating a UIButton and when the user clicks on it, the camera should pop up and allow the user to take a photo. I decided to add a UIActionSheet which allows the user to choose wether they want to choose a photo from the album, or whether they want to take a photo using the camera. Before I added the action sheet the button worked fine, when the user shaped the photo, the background image of the button was replaced by the photo taken by the UIImagePicker. But after I added the action sheet now the UIButtons image is not being replaced by the images taken from the UIImagePicker or from the users photo library
here is the associated code,
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
[self.navigationItem setHidesBackButton:NO];
[self.usernameField becomeFirstResponder];
uploadPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[uploadPhotoButton setImage:[UIImage imageNamed:#"uploadphotoicon"] forState:UIControlStateNormal];
uploadPhotoButton.frame = CGRectMake(0, 0, 80, 80);
uploadPhotoButton.clipsToBounds = YES;
uploadPhotoButton.layer.cornerRadius = 80/2.0f;
uploadPhotoButton.layer.borderColor = [UIColor colorWithRed:.102 green:.737 blue:.612 alpha:1.0].CGColor;
uploadPhotoButton.layer.borderWidth = 2.0f;
[self.view addSubview:uploadPhotoButton];
[uploadPhotoButton setCenter:CGPointMake(160, 128)];
[uploadPhotoButton addTarget:self action:#selector(uploadPhotoButton:) forControlEvents:UIControlEventTouchUpInside];
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex < 2) {
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
UIImagePickerControllerSourceType type;
switch (buttonIndex) {
case 0:
type = UIImagePickerControllerSourceTypePhotoLibrary;
break;
case 1:
type = UIImagePickerControllerSourceTypeCamera;
break;
default:
break;
}
imagePicker.sourceType = type;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:^{ }];
}
}
- (IBAction)signupDone:(id)sender {
NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([username length] == 0 || [password length] == 0 /*|| [email length] == 0*/){
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Oops!" message:#"Please enter a username, password, and email!" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alertView show];
}
else {
PFUser *newUser = [PFUser user];
newUser.username = username;
newUser.password = password;
[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:[error.userInfo objectForKey:#"error"] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alertView show];
}
else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
}
}
-(IBAction)uploadPhotoButton:(id)sender {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:#"Select Photo" delegate:self cancelButtonTitle:#"Nevermind" destructiveButtonTitle:nil otherButtonTitles:#"From Library", #"From Camera", nil];
[sheet showInView:self.view];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
uploadPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
uploadPhotoButton.frame = CGRectMake(0, 0, 80, 80);
uploadPhotoButton.clipsToBounds = YES;
uploadPhotoButton.layer.cornerRadius = 80/2.0f;
uploadPhotoButton.layer.borderColor = [UIColor colorWithRed:.102 green:.737 blue:.612 alpha:1.0].CGColor;
uploadPhotoButton.layer.borderWidth = 2.0f;
[self.view addSubview:uploadPhotoButton];
[uploadPhotoButton setCenter:CGPointMake(160, 128)];
[uploadPhotoButton addTarget:self action:#selector(uploadPhotoButton:) forControlEvents:UIControlEventTouchUpInside];
userImage = [info objectForKey:UIImagePickerControllerEditedImage];
[uploadPhotoButton setImage:userImage forState:UIControlStateNormal];
[self.navigationController dismissViewControllerAnimated:YES completion:NULL];
[self uploadImage];
You do not need to create another button,
Only you need to declare uploadPhotoButton in interface for global use in this controller and just replace the method below :
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:NULL];
UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
[uploadPhotoButton setImage:chosenImage forState:UIControlStateNormal];
// [self.navigationController dismissViewControllerAnimated:YES completion:NULL];
[self uploadImage];
}
In this code I first diss miss the image pickerViewController and just set the image on my button.

I want to use identifiers in .m in other .m (implementation file import) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
On cameraviewcontrolle.mr I take a picture or movie using UIImagePickerController. On completion, I call back to aanvraagviewcontroller.m.
I want to save the the picture by tapping on send button.
My question comes to this I think, how can I import .m file or take the picture/movie to aanvraagviewcontroller.m (I use Parse.com to save my PFObjects)?
This is cameraviewcontroller.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
// A photo was taken/selected!
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Save the image!
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
}
}
else {
// A video was taken/selected!
self.videoFilePath = (__bridge NSString *)([[info objectForKey:UIImagePickerControllerMediaURL] path]);
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Save the video!
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.videoFilePath)) {
UISaveVideoAtPathToSavedPhotosAlbum(self.videoFilePath, nil, nil, nil);
}
}
}
[self uploadMessage];
[self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popToRootViewControllerAnimated:YES];}
- (void)uploadMessage {
NSData *fileData;
NSString *fileName;
NSString *fileType;
if (self.image != nil) {
UIImage *newImage = [self resizeImage:self.image toWidth:320.0f andHeight:480.0f];
fileData = UIImagePNGRepresentation(newImage);
fileName = #"image.png";
fileType = #"image";
}
else {
fileData = [NSData dataWithContentsOfFile:self.videoFilePath];
fileName = #"video.mov";
fileType = #"video";
}
PFFile *file = [PFFile fileWithName:fileName data:fileData];
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"An error occurred!"
message:#"Please try sending your message again."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
else {// onderdeelAanvraag[#"file"] = file;
// onderdeelAanvraag[#"fileType"] = fileType;
// onderdeelAanvraag[#"recipientIDs"] = self.recipients;
//
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"An error occurred!"
message:#"Please try sending your message again."
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
else {
// Everything was successful!
[self reset];
}
// }];
}
}];
}
- (void)reset {
self.image = nil;
self.videoFilePath = nil;
[self.recipients removeAllObjects];
}
- (UIImage *)resizeImage:(UIImage *)image toWidth:(float)width andHeight:(float)height {
CGSize newSize = CGSizeMake(width, height);
CGRect newRectangle = CGRectMake(0, 0, width, height);
UIGraphicsBeginImageContext(newSize);
[self.image drawInRect:newRectangle];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resizedImage;
}
This is aanvraagviewcontroller.m (when send button is pressed, i want to save the picture/movie here);
- (IBAction)verstuurAanvraag:(id)sender {
NSString *onderdeelOmschrijving = self.onderdeelOmschrijvingField.text ;
NSString *autoOmschrijving = self.autoOmschrijvingField.text ;
if ([onderdeelOmschrijving length] == 0 ||
[autoOmschrijving length] == 0)
{
UIAlertView *alertView = [[ UIAlertView alloc] initWithTitle:#"Leeg veld" message:#"Vul de lege velden in" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alertView show];
}
else {
PFObject *onderdeelAanvraag = [PFObject objectWithClassName:#"Aanvragen"];
[onderdeelAanvraag setObject:[PFUser currentUser] forKey:#"Aanvrager"];
onderdeelAanvraag[#"OnderdeelOmschrijving"] = onderdeelOmschrijving;
onderdeelAanvraag[#"AutoOmschrijving"] = autoOmschrijving;
NSDate *date = [NSDate date];
onderdeelAanvraag[#"Datum"] =date;
onderdeelAanvraag[#"file"] = file;
onderdeelAanvraag[#"fileType"] = fileType;
onderdeelAanvraag[#"recipientIDs"] = self.recipients;
// Get random number between 0 and 999999
int nummer = arc4random() % 100000;
NSLog(#"nieuw nummer %d", nummer);
[onderdeelAanvraag setObject:[NSNumber numberWithInt:nummer] forKey:#"AanvraagNummer"];
[onderdeelAanvraag saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry!" message: [error.userInfo objectForKey:#"error"] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
else {
[self performSegueWithIdentifier:#"showRecipients" sender:self];
}
}];
}
}
I SOLVED PASSING UITEXTFIELD TEXT BY THIS ;
I solved passing textfield data passing with the segue method like here ;
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"showRecipients"]){
OntvangersViewController *controller;
controller = [segue destinationViewController];
controller.onderdeelOmschrijvingField = self.onderdeelOmschrijvingField;
controller.autoOmschrijvingField = self.autoOmschrijvingField;
controller.image = self.image;
controller.videoFilePath = self.videoFilePath;
NSLog(#"videofilepath %#", self.videoFilePath);
controller.recipients = self.recipients;
}
}
Your question is muddled and confused.
The code in a .m file is not shared with other .m files.
The whole point of the C .h header file is that the header file can be shared, while the implementation (.c, or .m for Objective C) is private, and not shared.
If you want a value to be visible to another class, or another object of the same class, you should define a property in the header file.
If you want to pass a value from one view controller to another, this topic has been covered Ad nauseam here and on other forums. There are at least 2 comments on your post pointing you to other threads covering the topic.

How to reduce audio file size in IOS

I am doing an application which get songs from mediapicker and saving it to my application.i want to reduce the size of file,but i got a sample named "AACConverter",i test the application but it is not reducing the file size.could any one help me in solving this problem.
- (IBAction)convert:(id)sender {
if ( ![TPAACAudioConverter AACConverterAvailable] ) {
[[[[UIAlertView alloc] initWithTitle:NSLocalizedString(#"Converting audio", #"")
message:NSLocalizedString(#"Couldn't convert audio: Not supported on this device", #"")
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(#"OK", #""), nil] autorelease] show];
return;
}
// Initialise audio session, and register an interruption listener, important for AAC conversion
if ( !checkResult(AudioSessionInitialize(NULL, NULL, interruptionListener, self), "initialise audio session") ) {
[[[[UIAlertView alloc] initWithTitle:NSLocalizedString(#"Converting audio", #"")
message:NSLocalizedString(#"Couldn't initialise audio session!", #"")
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(#"OK", #""), nil] autorelease] show];
return;
}
// Set up an audio session compatible with AAC conversion. Note that AAC conversion is incompatible with any session that provides mixing with other device audio.
UInt32 audioCategory = kAudioSessionCategory_MediaPlayback;
if ( !checkResult(AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory), "setup session category") ) {
[[[[UIAlertView alloc] initWithTitle:NSLocalizedString(#"Converting audio", #"")
message:NSLocalizedString(#"Couldn't setup audio category!", #"")
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(#"OK", #""), nil] autorelease] show];
return;
}
NSArray *documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
audioConverter = [[[TPAACAudioConverter alloc] initWithDelegate:self
source:[[NSBundle mainBundle] pathForResource:#"audio" ofType:#"mp3"]
destination:[[documentsFolders objectAtIndex:0] stringByAppendingPathComponent:#"audio.m4a"]] autorelease];
NSLog(#"destinatiion path is %#",[[documentsFolders objectAtIndex:0]stringByAppendingFormat:#"audio.m4a"]);
((UIButton*)sender).enabled = NO;
[self.spinner startAnimating];
self.progressView.progress = 0.0;
self.progressView.hidden = NO;
[audioConverter start];
}
- (IBAction)playConverted:(id)sender {
if ( audioPlayer ) {
[audioPlayer stop];
[audioPlayer release];
audioPlayer = nil;
[(UIButton*)sender setTitle:#"Play converted" forState:UIControlStateNormal];
} else {
NSArray *documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[documentsFolders objectAtIndex:0] stringByAppendingPathComponent:#"audio.m4a"];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer play];
[(UIButton*)sender setTitle:#"Stop" forState:UIControlStateNormal];
}
}
- (IBAction)emailConverted:(id)sender {
NSArray *documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[documentsFolders objectAtIndex:0] stringByAppendingPathComponent:#"audio.m4a"];
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:NSLocalizedString(#"Recording", #"")];
[mailController addAttachmentData:[NSData dataWithContentsOfMappedFile:path]
mimeType:#"audio/mp4a-latm"
fileName:[path lastPathComponent]];
[self presentModalViewController:mailController animated:YES];
}
#pragma mark - Audio converter delegate
-(void)AACAudioConverter:(TPAACAudioConverter *)converter didMakeProgress:(CGFloat)progress {
self.progressView.progress = progress;
}
-(void)AACAudioConverterDidFinishConversion:(TPAACAudioConverter *)converter {
self.progressView.hidden = YES;
[self.spinner stopAnimating];
self.convertButton.enabled = YES;
self.playConvertedButton.enabled = YES;
self.emailConvertedButton.enabled = YES;
audioConverter = nil;
}
-(void)AACAudioConverter:(TPAACAudioConverter *)converter didFailWithError:(NSError *)error {
[[[[UIAlertView alloc] initWithTitle:NSLocalizedString(#"Converting audio", #"")
message:[NSString stringWithFormat:NSLocalizedString(#"Couldn't convert audio: %#", #""), [error localizedDescription]]
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(#"OK", #""), nil] autorelease] show];
self.convertButton.enabled = YES;
audioConverter = nil;
}
There are various ways in which you can solve this problem.
In case you want the audio to play in background, you can use
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:#"BGM.mp3" loop:YES];
By using this, you can use a small audio clip which will be small in size, and play it in a loop. Same thing can be applied to Effect Audio as well.
Apart from that, decreasing the Bitrate of audio clip also helps in decreasing the size of file.
For all these editing operations, which includes editing/clipping/trimming sound clip, decreasing bitrate, saving in different formats, I'd suggest you use
Audacity (Open-source, free)
If you care about the size over the quality, maybe you want to conver the song to amr format.

Resources