Editor's Note: Don't miss the first article in this two-part series, "Building Interactive iPod Experiences."
One of the great joys about a device like the iPod is that it doesn't just do music. It does videos. It does text. It does games. It does pictures. You can use it as a portable hard drive. With the proper hardware, it can do radio and it can record voice memos and do even more. The device is so flexible, one is constantly finding new ways the Apple engineers have thought of to break out of the MP3-player box and give more power to both developers and end users. The iPod's Notes feature is a great example of this power.
iPod's boring-looking but surprisingly powerful Notes pack a wallop of possibility into the iPod's limited interface. It allows you to use iPods to create self-contained but user-driven presentations. In the first article of this series, "Building Interactive iPod Experiences," you discovered how to use the base features of iPod Notes to build interactive tours and lessons. This article steps it up a notch.
Here, you'll learn to take further control over your iPod Notes and add a more professional veneer. You'll discover how to create a "notes-only" museum mode, how to reuse already existing HTML source material, how to create custom menu presentations, how to control navigation, and more. This article presents some of the more exciting notes options that you can use to move beyond the basics. If learning about how notes work has captured your interest, this article will take you to the next level.
As with any computer, controlling your preferences lets you control your iPod. You specify the way your iPod displays notes by creating and editing a simple text file. The preferences file, preferences.txt, must be stored in the top Notes folder on your iPod. It consists of one or more <META> elements that specify the name of the preference and its settings. There are five possible settings, each of which can be set to either true or false. These settings both help you control the user experience and can make the development process more HTML-author friendly. Here's a quick rundown of these preferences.
NotesOnlyNotesOnly specifies whether your iPod displays all of its features, as you'd normally expect, or whether it limits the user to the notes you've created. When used, NotesOnly mode puts your user directly into Extras -> Notes. They cannot navigate out of there to the standard set of iPod menus until the preferences are reset at a computer--either by editing preferences or removing the preferences file completely. This ensures, for example, that the students who are supposed to be using the iPods to work on their Physics labs cannot spend their time playing MiniGolf and Tetris or listening to Phish. The default value for NotesOnly is FALSE, which allows for full iPod access.
<META NAME="NotesOnly" CONTENT="TRUE">
Tip: I have found NotesOnly mode extremely valuable while debugging. It limits all those times that you have to click Extras and then Notes to get down to see the notes you are working on.
NowPlayingNowPlaying controls whether your audio links transfer your user from the current note to the Now Playing page for that audio or not. When you set NowPlaying to FALSE, users remain on the notes page whenever they link to audio. The audio plays in the background, but the screen remains on the linking note. Setting NowPlaying to TRUE means that all links to audio will transfer the user to the Now Playing page and the user must press Menu to return to that note. The default value for NowPlaying is TRUE. This setting has no effect on links to pictures, folders, other notes, or video.
<META NAME="NowPlaying" CONTENT="FALSE">
LineWrapLineWrap determines how the iPod handles line feed (LF) and carriage return (CR) characters. By default, both are shown as used in the text file. Add two carriage returns, for example, to the middle of your text and both are displayed on the iPod. To make the notes ignore embedded LF and CR characters, as you would expect when writing HTML, set the LineWrap value to TRUE. The default value for LineWrap is FALSE.
<META NAME="LineWrap" CONTENT="TRUE">
HideAllTagsHideAllTags lets you cut and paste already existing HTML text by zapping extra tags from view while respecting paragraph (<P>, </P>) and break (<BR>, </BR>) tags. This has the effect of letting you display HTML source material without having to edit out your elements by hand. Anything between angle brackets goes away, leaving a clean and easy-to-read result. The HTML elements like bold or italics or lists are simply ignored. To hide tags, set HideAllTags to TRUE. The default value for HideAllTags is FALSE.
<META NAME="HideAllTags" CONTENT="TRUE">
ShowBodyOnlyShowBodyOnly takes HTML-source reuse to the next level. It hides all text that does not appear between <BODY> and </BODY>--but only if these elements appear in the source. Sensibly, if there are no <BODY> elements, the entire note is displayed. To use this feature, set ShowBodyOnly to TRUE. The default value for ShowBodyOnly is FALSE.
<META NAME="ShowBodyOnly" CONTENT="TRUE">
With .linx files, Apple provides a flexible, if strangely buggy, way to lay out menus for your notes. Any text file with a .linx extension is interpreted as a menu. Kind of. Let me explain how this works as simply as possible.
If you place a main.linx file (it can also be called index.linx, but just choose one to use) in your main Notes folder, it defines the way your main menu displays. It can have a TITLE element and it can have links (<A HREF="...">). Pretty much everything else inside the file gets ignored. A .linx file that looks like this:
<TITLE>Welcome to Figlet</TITLE>
<A HREF="MyPictures">View Pictures</A>
and a .linx file that looks like this:
<TITLE>Welcome to Figlet</TITLE>
Blah. Blah blah.
<A HREF="MyPictures">View Pictures</A>
Foo foo!
both produce the same main menu, which is shown in Figure 1.

Figure 1. Using .linx files allows you to create custom menus. Links appear in the order you choose. You can also provide custom titles.
You might assume that you can stick main.linx (or index.linx) files in any folder and they'll provide a default menu for that folder. But you can't. The main/index trick only works in your top-level folder. Put a .linx file (by whatever name) in any other folder and it adds an extra, custom menu as an extra menu item!
For example, I put the following main.linx file into my MyPictures folder as shown in Figure 2.
<TITLE>These Are My Pictures</TITLE>
<A HREF="foxnkit.jpg">A Fox and her Kit</A>
<A HREF="fruits.jpg">Fruit</a>
<A HREF="flwrvase.jpg">Flowers in a Vase</A>
<A HREF="rotaryphone.jpg">Classic Telephone</A>

Figure 2. Adding a main.linx file to a submenu can produce unexpected results.
Figure 3 shows the resulting menu. All the folder files are listed, as well as a link for the .linx file. The TITLE element in the .linx file sets the name of the menu item.

Figure 3. Using a .linx file (by any name) in submenus produces unexpected results.
In order to get the result that I really wanted, which was to replace the folder-as-menu contents of the MyPictures folder, you need to link directly to the .linx file from main.linx in your main Notes folder and abandon using links directly to folders. This code produces the menu shown in Figure 4. Feel free to name your secondary .linx files as you wish. The whole main/index naming convention only applies to the home Notes folder.
<TITLE>Welcome to Figlet</TITLE>
<A HREF="MyPictures/main.linx">View Pictures</A>

Figure 4. By linking to the .linx file and not to the subfolder, a correct result was achieved.
One thing you've got to be aware of is that .linx files slightly mess up NotesOnly mode. There's a bug in the current firmware. After dismounting your iPod, you'll end up at the main iPod menu and not directly in Notes. Navigate down into Extras -> Notes when this happens. Fortunately, once there, you're there. NotesOnly mode takes over and becomes the top level. If you use .linx files, be prepared for this extra step until Apple fixes this bug. You'll have to manually enter Extras -> Notes before delivering your product.
In addition to .linx files, Apple also provides single-link .link file support. As these files are even buggier than their multi-link big brothers, I cannot recommend using them and will not discuss them further in this article. If you want to learn more about them, consult Apple's iPod Notes Feature Guide (PDF).
|
Whenever you navigate through your iPod menus--regular menus as well as notes--the iPod maintains a history stack to keep track of your progress. Pressing the Menu button moves you back one step at a time through this stack. Because there are times that you might want to either skip one stage or reset the stack completely, Apple offers a couple of modifier tags for your anchor elements. Here you'll see what these tags are and why you might want to use them.
POPALLSay that your user just completed a tour or a lesson. You want him or her to be able to jump right back to your main menu without either having to press Menu a few hundred times or leaving a history track through the already-completed segment. The POPALL tag empties the entire history stack, allowing you to return to the main menu without a history.
To use the tag, just add it to your anchor that links to the main page. The POPALL tag only links to the top of the notes hierarchy--to either the Notes folder itself or the main.linx (or index.linx) file. You cannot use it to link to an arbitrary file, whether or not it's in the home Notes folder.
<A HREF="/" POPALL>Finish this tour</A>
<A HREF="/main.linx" POPALL>Leave this lesson</A>
NOPUSHSometimes a menu or screen helps users choose how they want to explore parts of your tours or lessons, but they're not really helpful when you visit them a second time. For example, you might ask your user whether they want to listen to a presentation or read it, or you might choose whether to play the audio track with the background music or not. Similarly, introductory screens might not be as helpful the second, third, or fourth time you have to page through them when returning up the history stack. When you have a note that really only works in a forward direction, use the NOPUSH tag to link to it without letting it enter the history stack. Your user will see it only once, when navigating through it from higher to lower in the notes tree.
<A HREF="introscreen.txt" NOPUSH>Start Your Tour</A>
<A HREF="/chooseTextOrAudio.txt" NOPUSH>Read or Listen</A>
Note files use Latin1 encoding by default unless the iPod language is set to Japanese, Korean or Chinese. (In which case, those languages are used to set the encoding.) You can tag note files to override the standard encoding as follows:
<?xml encoding="Korean" ?>
Valid encoding schemes include Latin1, MacRoman, MacJapanese, Traditional Chinese, Simplified Chinese, Korean, UTF8 Unicode, and UTF16 Unicode. Always place the encoding tag at the very top of a note, and only include one encoding per file. Please refer to Apple's documentation for further details about encoding schemes, character entities, URI encoding, and so on.
Set your iPod to report errors by adding <ERROR> to your notes. You'll see a list of any errors found while parsing that notes file, including badly formatted tags, dead links, and so forth. Figure 5 shows an error report for a note with a bad link.

Figure 5. The <ERRORS> tag generates an error report.
Make sure to remove all <ERROR> mentions after you finish debugging your note. Notes without any errors that are tagged with the error code will display as a simple blank screen. This can be both confusing and annoying when you've just forgotten to remove the tag.
It wouldn't be far off the mark to accuse Apple of over-engineering some of their products. When they deliver such delightful gems as iPod Notes, you really have to forgive them. It's a joy to discover these little-known but extremely useful extras and get the opportunity to explore and see how they can be used to get more value from your equipment.
This article and the previous one in this series have covered a fair majority of the features currently available in iPod Notes. You've read how to create notes and customize them, link them together, and produce menus that let users decide how they want to proceed. You've seen how to set up your iPod for "notes-only" museum mode and learned how to incorporate HTML text in your presentations, without having to remove tags by hand. You've also discovered how to control your history stack and debug your notes, and more.
I hope this article has inspired you to dig into iPod Notes and to try them out for yourself. To discover more about iPod Notes and how to develop your own notes presentations, please visit the following Apple links.
Erica Sadun has written, co-written, and contributed to almost two dozen books about technology, particularly in the areas of programming, digital video, and digital photography.
Return to the Mac DevCenter.
Copyright © 2009 O'Reilly Media, Inc.