I'm using the code at https://developer.apple.com/library/ios/qa/qa1730/_index.html#//apple_ref/doc/uid/DTS40010629 to trim audio and it was working until the iOS 7 update. The media gets cropped to the correct duration and plays as such but when it is viewed in iTunes the cropped clip shows up with duration metadata that is the same as the original audio file. Any help would be greatly appreciated. Thanks.
UPDATE:
AVMutableMetadataItem *titleMetadata = [[AVMutableMetadataItem alloc] init];
titleMetadata.keySpace = AVMetadataKeySpaceCommon;
titleMetadata.key = AVMetadataCommonKeyTitle;
titleMetadata.value = #"Title";
AVMutableMetadataItem *durationMetadata = [[AVMutableMetadataItem alloc] init];
durationMetadata.keySpace = AVMetadataKeySpaceID3;
durationMetadata.key = AVMetadataID3MetadataKeyLength;
durationMetadata.value = [NSNumber numberWithDouble:30.0];
NSArray *metadeta = [[NSArray alloc] initWithObjects:titleMetadata,durationMetadata, nil];
exporter.metadata = metadeta;
Related
//setup service config
AWSServiceConfiguration *serviceConfiguration = [[AWSServiceConfiguration alloc] initWithRegion:CognitoIdentityUserPoolRegion credentialsProvider:nil];
//create a pool
AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:CognitoIdentityUserPoolAppClientId clientSecret:nil poolId:CognitoIdentityUserPoolId];
[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration:serviceConfiguration userPoolConfiguration:configuration forKey:#"UserPool"];
AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:#"UserPool"];
pool.delegate = self;
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoIdentityUserPoolRegion
identityPoolId:CognitoIdentityPoolId];
AWSServiceConfiguration *configuration1 = [[AWSServiceConfiguration alloc] initWithRegion:CognitoIdentityUserPoolRegion
credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration1;
Above is my code in appdelegate.
I'm using sample from AWS document "CognitoYourUserPool" to login.
And trying to call API using Generated SDK for iOS.
API_Client *apiInstance = [API_Client defaultClient];
[apiInstance setAPIKey:#"xxxxxxxxxxxxxxxxxxxxxx"];
[[apiInstance presetTypeGet] continueWithBlock:^id _Nullable(AWSTask * _Nonnull t) {
NSLog(#"error: %#",t.error);
NSLog(#"result: %#",t.result);
return nil;
}];
I did call the API after logged in. but it's error.
I dont know why for now.
Please help me. If you need more information please ask.
Thank you very much.
Try this:
AWSCognitoIdentityUserPoolConfiguration *configuration = [[AWSCognitoIdentityUserPoolConfiguration alloc] initWithClientId:CognitoIdentityUserPoolAppClientId clientSecret:nil poolId:CognitoIdentityUserPoolId];
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoIdentityUserPoolRegion identityPoolId:CognitoIdentityPoolId];
AWSServiceConfiguration *configuration1 = [[AWSServiceConfiguration alloc] initWithRegion:CognitoIdentityUserPoolRegion credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration1;
[AWSCognitoIdentityUserPool registerCognitoIdentityUserPoolWithConfiguration: configuration1 userPoolConfiguration:configuration forKey:#"UserPool"];
AWSCognitoIdentityUserPool *pool = [AWSCognitoIdentityUserPool CognitoIdentityUserPoolForKey:#"UserPool"];
pool.delegate = self;
After 2 days, I figure it out.
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoIdentityUserPoolRegion
identityPoolId:CognitoIdentityPoolId identityProviderManager:pool];
Need to set identityProviderManager.
Thank you very much.
Is there a service to be able to add a URL to the iOS Safari's Reading List from in a app.
I would have a url to add and a UIWebView,but I have researched and I can't find anything.
Here is my working UIActivityViewController.
-(IBAction)actionButton:(id)sender;{
NSLog(#"shareButton pressed");
NSURL *URL = [NSURL URLWithString:self.feedItem[#"url"]];//this is your text string
NSArray *activityItems = #[URL];
ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init];
TUSafariActivity *TUSafari = [[TUSafariActivity alloc] init];
MLCruxActivity *cruxActivity = [[MLCruxActivity alloc] init];
NSArray *applicationActivities = [NSArray arrayWithObjects:TUSafari,chromeActivity,cruxActivity, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities: applicationActivities];
activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact];
[self presentViewController:activityVC animated:TRUE completion:nil];
}
UPDATE: iOS 7 added an API to accomplish this:
#import <SafariServices/SafariServices.h>
SSReadingList * readList = [SSReadingList defaultReadingList];
NSError * error = [NSError new];
BOOL status =[readList addReadingListItemWithURL:[NSURL URLWithString:urlToAdd] title:titleToAdd previewText:previewText error:&error];
if(status)
{
NSLog(#"Added URL");
}
else NSLog(#"Error");
Currently (iOS SDK 6.1) there is no way to add a item to the Reading List from a third party app.
There are some alternatives like Readability you could use.
I'm developing two separate projects (for iphone and ipad). Device camera scans barcodes using zxing library and populates their text to UILabel. On iPhone everything is working normally but on ipad zxing can't recognize barcodes.
this is my launch code:
-(IBAction)scanWithCameraButtonPressed:(id)sender
{
NSLog(#"scanWithCameraButtonPressed: called");
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
NSMutableSet *readers = [[NSMutableSet alloc ] init];
//QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
//[readers addObject:qrcodeReader];
//AztecReader *aztecReader = [[AztecReader alloc] init];
//[readers addObject:aztecReader];
//DataMatrixReader *dataMatrixReader=[[DataMatrixReader alloc] init];
//[readers addObject:dataMatrixReader];
//MultiFormatOneDReader *multiFormatOneDReader=[[MultiFormatOneDReader alloc] init];
//[readers addObject:multiFormatOneDReader];
MultiFormatUPCEANReader *multiFormatUPCEANReader=[[MultiFormatUPCEANReader alloc] init];
[readers addObject:multiFormatUPCEANReader];
widController.readers = readers;
NSBundle *mainBundle = [NSBundle mainBundle];
widController.soundToPlay =
[NSURL fileURLWithPath:[mainBundle pathForResource:#"beep-beep" ofType:#"aiff"] isDirectory:NO];
[self presentModalViewController:widController animated:YES];
}
I'm testing theese applications
on iphone 3gs with iOS 5.0 <- works
on ipad2 with iOS 5.1 <- can not recognize
all the zxing linking process was the same, code is the same.
Help me please, where the problem is?
In .plist file I keep NSURLs of audio files from iPod library. I need to initialize MPMediaItemCollection items by these urls.
How can I do that? Thanks.
I found the solution
keep it here, if someone will need same thing once
MPMediaQuery *everything = [[MPMediaQuery alloc] init];
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery)
{
if ([savedUrl isEqual:[song valueForProperty:MPMediaItemPropertyAssetURL]])
{
ownMediaItemCollection = [MPMediaItemCollection collectionWithItems: [NSArray arrayWithObject:song]];
}
}
[everything release];
I'm looping through all the songs from an iPhone's music library using the following code:
NSArray * songs = [[NSArray alloc] initWithArray:[[MPMediaQuery songsQuery] collections]];
for (MPMediaItemCollection * item in songs){
NSString * persistentID = [[[item representativeItem] valueForProperty:MPMediaItemPropertyPersistentID] stringValue];
// Do something with it.
}
[songs release];
Pretty basic stuff.
I'm getting the PersistentID as an NSString because I need to write it to an XML file (for transmission over a network to another device). Hence the reason I can't just leave it as an NSNumber.
The other device will then ask for the iPhone to play a track by transmitting the PersistentID back again.
At this point, the iPhone has an NSString of the PersistentID of the track it should play.
It would be combersome to loop through every song again and compare PersistentIDs until I find the track I want, so I'm trying to use the MPMediaPropertyPredicate to have the iPhone search for me.
I'm using the following code for the search:
MPMediaPropertyPredicate * predicate = [MPMediaPropertyPredicate predicateWithValue:persistentID forProperty:MPMediaItemPropertyPersistentID];
MPMediaQuery * songsQuery = [[MPMediaQuery alloc] init];
[songsQuery addFilterPredicate:predicate];
if ([[songsQuery items] count]){
MPMediaItem * item = [[songsQuery items] objectAtIndex:0];
// Play item.
}
[songsQuery release];
Where persistentID is the NSString from earlier.
Weirdly, this works for some songs, not for others. i.e, sometimes the items array is not empty, even though I'm passing an NSString, not an NSNumber.
I'm wondering if there's a way to convert my NSString back to the NSNumber it came from, and how I can do that.
UPDATE: I've tried the NSNumberFormatter, I've also tried something like:
[NSNumber numberWithFloat:[persID floatValue]];
I've tried all the standard ways of doing it without prevail.
This is working pretty well, no problems so far:
unsigned long long ullvalue = strtoull([persistentID UTF8String], NULL, 0);
NSNumber * numberID = [[NSNumber alloc] initWithUnsignedLongLong:ullvalue];
MPMediaPropertyPredicate * predicate = [MPMediaPropertyPredicate predicateWithValue:numberID forProperty:MPMediaItemPropertyPersistentID];
[numberID release];
// And so on.
Hope this helps anyone else who ran into this problem.
If I understand you correctly, you're trying to convert an NSString to an NSNumber. To do this, you can use a NSNumberFormatter. Take a look at the numberFromString: method.
NSNumberFormatter Class Reference
I just had to do the same thing. The Query Predicate for MPMediaItemPropertyPersistentID has to be passed in as NSNumber. I found this answer on converting NSString to NSNumber from another StackOverflow post:
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber * persistentIDasNumber = [f numberFromString:persistantID];
[f release];
MPMediaPropertyPredicate * predicate = [MPMediaPropertyPredicate predicateWithValue:persistentIDasNumber forProperty:MPMediaItemPropertyPersistentID];
This worked for me.
I ran into something very similar and worked out the following:
NSNumber *musicIdentifier = [[[NSNumberFormatter alloc] init] numberFromString: persistentID];
MPMediaQuery *query = [[MPMediaQuery alloc] initWithFilterPredicates:[NSSet setWithObject:[MPMediaPropertyPredicate predicateWithValue:musicIdentifier forProperty:MPMediaItemPropertyPersistentID]]];
MPMediaItem *item = query.items.firstObject;