SpriteKit playSound doesn't play m4a files? - objective-c

I want to use the playSoundFileNamed: Method to play a background soundfile as loop, which I copied into the project as usual, but the problem is, that the program stops at the sound code line...
SKAction* playSound = [SKAction playSoundFileNamed:#"backgroundMusicLoop.m4a" waitForCompletion:NO];
[self runAction: [SKAction repeatActionForever:playSound]];
It doesn't happen anything (and I tried it not in the simulator, but on a real device) !
I tried to play a wav file and there was no error, but wavs have a lot bigger filesize...
Hope someone knows about a solution :)

UPDATED
Change your waitForCompletion from NO to YES.
Having it set to NO, means that the action will always repeat itself without waiting for the sound to play to end. In effect it gets stuck at the beginning and has no chance to play through.
(Brain fart on my part for not seeing that the first time around!)
ORIGINAL
The m4a sound format seems to have issues with the playSoundFileNamed:waitForCompletion:. Try another format such as mp3 or caf.
If you absolutely need to use m4a then use AVAudioSession to play your sounds, music.
In case you don't know how to convert formats using iTunes, here are Apple's instructions for it:
Saving a copy of a song in a new file format
When converting from a compressed to uncompressed file format (for example, from MP3 to AIFF) you shouldn't notice any reduction in sound quality. However, when converting between compressed formats (for example MP3 and AAC), you may notice a reduction in the sound quality. For the best results, if you want your music encoded in a different file format, you should import the music again from the original source using the new encoding format.
To convert a song's file format Open iTunes Preferences. Windows:
Choose Edit > Preferences. Mac: Choose iTunes > Preferences. Click
the General button, then click the Importing Settings… button in the
lower section of the window. From the Import Using pop-up menu, choose
the encoding format that you want to convert the song to, then click
OK to save the settings. Select one or more songs in your library,
then from the File > Create New Version menu, choose one of the
following (the menu item changes to show what's selected in your
Importing preferences): Create MP3 version Create AAC version Create
AIFF version Create WAV version Create Apple Lossless version If you
haven't imported some songs into iTunes yet, you can import and
convert them at the same time. This will create a converted copy of
the file in your iTunes Library based on your iTunes preferences. To
convert all the songs in a folder or on a disk, hold down the Option
key (Mac) or Shift key (Windows) and choose File > Create New Version
Convert [import preference setting]. The Import preference setting will match what you chose in step 3. iTunes will prompt you for the
location of the folder or disk you want to import and convert. All the
songs in the folder or on the disk will be converted. Note: Older
purchased songs are encoded using a Protected AAC format that prevents
them from being converted. If you need to convert these to another
format, follow the instructions in this article to upgrade them.
The song in its original format and the newly converted song appear in
your library.

Related

Photoshop to unity

Hello I made a spritesheet in photoshop. The process to make the spritesheet was fairly easy. The issue is when importing to Unity I get a white background and I don't know how to remove the white background from my spreadsheet in unity. I have taken the following steps to resolve this issue
First unchecked the background in photoshop.
Second I tried to remove background from each individual image in photoshop.
But no luck can someone help.
You can select the asset and change its type to Sprites, instead of Default (in the Inspector); if you've already done that, how about trying .png files?
In one of the updates to Unity of last year, they removed the option to use the image transparancy as alpha when using .psd files. The option was a checkbox in the import setting of the image, which is no longer shown.
You can however use an import preset with a preset that still has this option set.
What you can do is:
Create a preset when in the texture-importer panel. How to make a preset? What is the texture-import panel?
Open the file which was created (e.g. myimporter.preset). You could use a file explorer in your project and search for the name
Then set these values to 1:
propertyPath: m_PSDRemoveMatte
propertyPath: m_PSDShowRemoveMatteOption
Apply this preset to all your psd files inside unity.
Now, importing a .psd file should work fine with transparancies.
Note: Unity's intent was for users to import .png files when dealing with transparancies. But I found it annoying to manually re-import all my .png files when i made changes to the .psd file.

How To Localize an iPhone App

I am trying to find a step by step tutorial on how to localize an iphone App. I have english and I'm looking to add french. The documentation is available but it hardly comes close to giving you clear instructions on how to implement it from start to finish.
Below is the step by step walkthrough that I was looking for. It is found Here
Hope it helps all of you as it did m.
This is a guest post by Sean Berry, a developer of math apps for iPhone, iPad, and iPod Touch.
Me Gusta Localization!
Although the English-speaking App Store market is the largest, there are still plenty of other iPhone users in the world and you can greatly increase their user experience by supporting their native language.
The good news is Apple has made it very easy to make your apps work with multiple languages through some API calls and built-in Xcode support. The process of doing this is called localization, and that’s what I’ll be showing you how to do!
In this iPhone app tutorial, you will be localizing a sample app I prepared called iLikeIt which was inspired by the rage comics in Ray’s post about in-app purchases. The app is very simple – it displays some ideal sales data, and when you tap ‘You like?’ a face appears, scales up, and fades away.
But right now it’s English only – so vamos a traducir!
This iPhone app tutorial will be using Xcode 4.6.1, so if you haven’t upgraded already, why not use this as an excuse to do so?
Getting Started
The first step is to download the iLikeIt starter project that we’ll be localizing in this iPhone app tutorial.
Build and Run the app, and you should see the following appear after you tap ‘You like?’:
We have 3 things to localize here:
Text: sales data
UI Element: ‘You like?’ button
and finally the image (it has text!)
Separating text from code
Like most projects, this project has some hardcoded strings in the code. We need to pull all of these hardcoded strings into a separate file so we can localize them.
The way you do this in Xcode is create a “.strings” file to contain all of the strings your projects needs. Then you’ll replace the hardcoded strings with a function call to look up the appropriate string from the “.strings” file based on the current language.
Let’s try this out. Go to File\New\New File. Choose iOS\Resource\Strings File, and click Next, as shown in the screenshot below. Name the new file Localizable.strings, and click Save.
Note that Localizable.strings is the default filename iOS looks for when dealing with localized text. If you don’t use this, you’ll have to specify the name of our .strings file every time.
The format for the strings file is:
"KEY" = "CONTENT";
So for our ‘Yesterday you sold %# apps’ and ‘You like?’ text add in:
"Yesterday you sold %# apps" = "Yesterday you sold %# apps";
"You like?" = "You like?";
Now switch to ViewController.m, and find the viewDidLoad method. Right now it sets the text as:
self.numAppsLabel.text = [NSString stringWithFormat:#"Yesterday you sold %# apps", #(1000000)];
[self.likeButton setTitle:#"You like?" forState:UIControlStateNormal];
We want it to instead read from our .strings file. To do that, change the current line to use a macro called NSLocalizedString as shown below:
self.numAppsLabel.text = [NSString stringWithFormat:NSLocalizedString(#"Yesterday you sold %# apps", nil), #(1000000)];
[self.likeButton setTitle:NSLocalizedString(#"You like?", nil) forState:UIControlStateNormal];
If you’re curious what the NSLocalizedString macro does, control-click on NSLocalizedString and choose Jump to Definition. You’ll find that it’s defined as follows:
#define NSLocalizedString(key, comment) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:#"" table:nil]
So basically, it’s using the localizedStringForKey method to look up the string for the given key, in the current language. It passes nil for the table name, so it uses the default strings filename (Localizable.strings). For full details, check out Apple’s NSBundle Class Reference.
One other thing to note. The macro takes a comment as a parameter, but seems to do nothing with it! This is because instead of manually typing in each key/value pair into Localizable.strings like we’ve been doing, you can use a tool that comes with the iPhone SDK called genstrings to do this automatically (which can be quite convenient for large projects).
If you use this method, you can put a comment for each string that will appear next to the default strings as an aid for the translator. For example, you could add a comment indicating the context where the string is used.
Enough background info – let’s try it out! Build and run your project, and it should say the same text on the main screen just as before. But where’s the Spanish? Now that we’re set up it’s a cinch.
Adding a Spanish Localization
To add support for another language, click on the blue iLikeIt project folder on the left pane, select the Project in the next pane (NOT the Target), and under the Info tab you’ll see a section for Localizations. Click the + and choose Spanish (es).
You’ll see another screen asking you which files you want to localize, keep them all selected and click Finish. It’s ok that you don’t see Localizable.strings yet! We’ll get to it soon.
At this point, Xcode has set up some directories containing a separate version of InfoPlist.strings and MainStoryboard.storyboard for each language you selected, behind the scenes. To see this for yourself, open your project folder in Finder, and you’ll see the following:
See en.lproj and es.lproj? They contain our language-specific versions of files.
‘en’ is the localization code for English, and ‘es’ is the localization code for Spanish. If you’re curious, here’s the full list of language codes.
When iOS wants to get the English version of a file, it will look in en.lproj, but when it wants the Spanish version of a file it will look in es.lproj.
It’s that simple! Put your resources in the appropriate folder and iOS will do the rest.
But wait, what about Localizable.strings? To let Xcode know you want it localized, select it on the left pane, and open the File Inspector in the right pane. There you will see a button labeled Localize, click it, choose English (because it’s currently in English), and finally click Localize.
Now on that right File Inspector panel it shows which languages this file belongs to, add it to the Spanish localization by checking that box to the left of Spanish.
Go back to the left panel and click on the arrow next to Localizable.strings so it shows the sub-elements. You’ll see now we’re working with two versions of this file:
To change the text for Spanish, select Localizable.strings (Spanish) and change the text to read:
"Yesterday you sold %# apps" = "Ayer le vendió %# aplicaciones";
"You like?" = "~Es bueno?~";
Your app is worldly now! Let’s make sure it worked…
To make your simulator show Spanish, go into Settings.app and choose General -> International -> Language -> Espanol.
Delete the app and select Project\Clean to get a fresh build and install. When you build and run you should see:
Locale versus Language
Let’s make that number look better by adding some formatting. Replace this code:
self.numAppsLabel.text = [NSString stringWithFormat:NSLocalizedString(#"Yesterday you sold %# apps", nil), #(1000000)];
With this:
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *numberString = [numberFormatter stringFromNumber:#(1000000)];
self.numAppsLabel.text = [NSString stringWithFormat:NSLocalizedString(#"Yesterday you sold %# apps", nil), numberString];
Build and Run and the number will be a lot easier to read.
But here’s the thing, in Spain they don’t format their numbers like that. They write “1.000.000″ instead of “1,000,000″, but if you change the iOS simulator’s language to Espanol, you’ll still see commas used to separate the zeroes. The reason being is that number formatting is based on the region/locale, not the language. To see how someone in Spain will see that number, go into Settings -> General -> International and change Region Format to Spanish -> Spain.
When you open up the app again this is what you should see:
We got that functionality for free, just for using Apple’s NSNumberFormatter class! It pays to do things Apple’s way, don’t fight it.
Images
Since we have text in our image we need to localize it. Having some English in an otherwise Spanish app would look amateur.
Select ilike.png and add a localization for Spanish (you’re an old pro at this now!) (if you forgot, select it on the left panel, and in the File Inspector panel on the right, click the Localize button. Then after allowing Xcode to place the default copy into en.lproj, check the Spanish box on the right panel.)
Check out the project folder. ilike.png has been added to the English folder (en.lproj) and then copied to the Spanish folder (es.lproj). To make a different image show up for the Spanish version, we simply overwrite the image in the Spanish folder.
I’ve also included it in the starting project, saved as megusta.png.
Rename it to ilike.png and move it into the Spanish folder (es.lproj), overwriting the copied English version.
Clean and rebuild and you should be done! Switch your simulator to Espanol to see…
Congrats! That’s the bulk of localization.

How to show document preview in iCloud conflicts sheet in Mac App using NSDocument

I am creating a Mac App, using NSDocument, that stores a custom class of documents to iCloud.
I was able to get the program to store documents to iCloud quite easily by just Code Signing it, Sandboxing it, and adding iCloud entitlements; however, I'm still encountering a problem where when I trigger an iCloud conflict and the program drops down the sheet allowing the user to resolve the conflict the rows in the sheet do not show the small image of the document (like Preview and TextEdit do).
Additionally, when I click on the area where the image should be (it's blank) it opens up a Quick Look window that just displays an image of the Document Icon together with some other information as opposed to a snap shot of the actual file like Preview and TextEdit do.
I have not found any information in Apple's documentation that explains what I need to do to implement the same behaviour as Preview and TextEdit.
So far I've been surprised by how easily I've been able to get all of the functionability of not only the Auto Saves and the Versions browser, but also saving to the Cloud. NSDocument seems to do all of this for the developer (resolving iCloud Conflicts, etc.), as Apple's documents says it does, but again I'm not getting this other behaviour and I don't want to reinvent the wheel by writing code that is not needed.
I'm thinking that the answer might lie somewhere with implementing a Quick Look thumbnail (for the small image in the table in the sheet) and a Quick Look preview for the larger preview of the document when that in the sheet is clicked on, but this seems like a lot of work and I'm afraid of losing some of the other build-in functions of NSDocument if I start "trapping" NSDocument routines up the food chain so to speak.
Has anyone else encountered this problem and found the easiest solution?
Update: Dec. 25/12
I've finally figured out that the problem is I need a QuickLook generator to display both a QL Thumbnail (which shows up in the table in the conflicts sheet) and a QL Preview (which is displayed when a user clicks on the Thumbnail)
I ended up creating the QL generator project, and afterwards creating a workspace which I added my main project and the QL generator project to. After that I added a Copy Files Build Phase to the main project to copy the QL generator into the main Application bundle.

Changing OS file icons using AIR app

I am building an AIR app which will be kind of like Dropbox. It will allow users to sync their files between various OSs. What I would like to know is that how can i change the default file system's file icons (add an overlay for eg) for states like - Synced and Syncing, the way Dropbox does it ??
On Windows i found out that Dropbox edits the registry files to insert the overlay icons..not yet sure how they do it in MAC OS X though.
I saw some threads here asking similar questions about AIR, but none referencing how to change file's icons. Hoping to get a solution for this from the various experts .. Please suggest any ideas if you know how it can be accomplished. Much thanks.
A simple yet effective solution would be to use icons that are only internal to your application : just embed in your application files some transparent pictures representing the various states of your files (with only the small part telling in which state it is, with the rest totally transparent), that you will add at runtime above the displayed icons.
Since you can get the actual icon of your files, just draw them into a BitmapData (if needed) & add an overlay with theses custom images, using the one related to your file's state in your application.
And one step further could be to store in your AIR application folder any resulting icons for future use (check what types of files you already have, and if your new file type isn't in thoses, export the various icons with your custom overlays to PNG files directly on the user device, for re-loading them the next time the application is opened).

iTunes Connect sends email about a issue with icon file, how to fix?

This is the email:
Dear developer,
We have discovered one or more issues with your recent binary submission for "Bla". Before your app can be reviewed, the following issues must be corrected:
Corrupt Icon File - The icon file 72 x 72.png appears to be corrupt.
Once these issues have been corrected , go to the Version Details page and click Ready to Upload Binary. Continue through the submission process until the app status is Waiting for Upload and then use Application Loader to upload the corrected binary.
I have change the file and re-upload the app, but I got the email again.
As Michael Dautermanm says.
Make sure "compress png's" is turned off in the build settings.
thanks
Can you open the file in Preview, and choose 'Tools' -> 'Show Inspector'? The file may be using some PNG format features that Apple don't like. They want RGB, 8 bit depth, no alpha. See the Custom Icon and Image Creation Guidelines.
For comparison, here are screenshots of the Preview Inspector, showing properties of an icon for an app that was accepted. If you're unsure, post similar screenshots for the properties of your picture.
The "Pixels Per Meter" part may or may not appear. It wasn't there when I first opened some icon files five minutes ago, and now it appears for every PNG I open. Weird.
Edit: also check the icon entries in your 'Info.plist', or the 'Info' tab for your Target. (These are not the same thing, as I just spent several hours discovering. Settings in the 'Info' tab override your 'Info.plist'.) As of the iOS 5.1 SDK, these include Icon file (a string), Icon files (an array), and Icon files (iOS 5) (a dictionary containing at least one dictionary containing an array). XCode seems to add your launch images to this list too. Don't rely on it to keep the list tidy - I have sometimes found outdated filenames in mine.
For further comparison, here's what ended up in the Info.plist of a valid app. Your filenames may be different, as long as they match the resources in your project.
I'm the developer of the app Pillboxie. I have been having the same issue as you, but I believe I may have finally found a solution.
Before proceeding with my suggestion, make sure that your Info.plist and all icon filenames appear exactly as Apple requires. Keep checking the documentation to make sure you're up-to-date, but Dondragmer's recommendation looks correct to me.
I created all my image resources, including app icons, in Photoshop, exporting for web as PNG-24's. Because Pillboxie has numerous images, setting "Compress png's" to YES in the build settings helps me save several megabytes of space. I was getting the same error as you until I tried turning off this compression, as Evaristoyok suggests. However, my app jumped up several mb. I hoped to find a better way.
Tonight I found the following link: article. In it the author suggests to make sure that "Interlaced" is NOT selected in Photoshop when exporting images in the Save For Web & Devices dialog window. I re-exported all icon and launch images with this disabled, and it solved my issue. I was able to submit my app and still leave png compression enabled.