Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The iTunes applet you developed in this chapter does not distinguish among multiple matching tracks with the same name. For example, you may have two tracks with the same name that were recorded by a different artist or on a different album. The user won't know that when presented with the list of choices. Modify the program so that each track provides the artist and album in the list of choices presented to the user (you can use the format name – artist – album) in the list.
Modify the iTunes applet so that if an asterisk is entered for the song name a randomly selected track is played.
Modify the iTunes applet so the three buttons labeled Title, Artist, and Album are offered to the user instead of OK, and Cancel. (Because display dialog only supports three buttons, you can't offer a Cancel button here.) The track should be selected from iTunes based on the button that is clicked. So, for example, if the user enters Springsteen and then clicks Artist, you display all tracks in the library playlist whose artist is Springsteen.
As noted in the chapter, after you select a song, the next songs in your library continue to play. Implement the following strategy: Keep a playlist called Play Just One in your library. If the playlist doesn't exist, create it. Remove any previous track from the playlist, add the selected track, and then play it. After playing the single track, iTunes should stop playing. Note: You need to change the playlist property of the track reference to refer to the track from the Play Just One playlist in order for this to work. (Why?)
Based on your solution to Exercise 4, modify the iTunes applet so that more than one song can be queued for playing. After the track has been selected, check the player's state. If the state of the player is not stopped, and it's playing a track from your Play Just One playlist, simply add the song to that playlist. However, if the player's state is stopped, remove any tracks from the Play Just One playlist and add the selected track.
Turn the iPhoto applet into a droplet so that, if a folder of images is dropped on it, the applet creates a new album from the images in the folder. If the applet is started in the normal way, which is by opening it from the Finder or double-clicking its icon, the applet should prompt for the name of the folder as before.
The iPhoto applet generates an error if an album already exists with the same name as the selected folder. Modify the program so that when this happens, the user is prompted to key in a different name for the album.
Count the number of images added to the new album by the iPhoto applet. If none are added, display a dialog and delete the empty album. Use the iPhoto command
remove album name
to delete the album called name.
Based on the results of Exercise 8, display a dialog at the end of the program's execution that informs the user of the number of files that were added to the album. Also, have it list (using choose from list) the names of the files that were not added to the album.
Convert the iDVD applet into a droplet so that it creates a DVD from a folder of images dropped onto it.
Modify the IDVD applet to convert an iPhoto album to a DVD, instead of a folder of images. Base your changes on the following handler called getAlbum, which prompts the user to select an album in iPhoto and returns the selected album. Use the image path property of each photo in the album to get its path name:
on getAlbum()
display dialog "Select an album in iPhoto and click Continue" buttons ¬
{"Continue", "Cancel"} default button 1
tell application "iPhoto"
activate
repeat
try
set sel to selection
set theAlbum to first item of sel
if (class of theAlbum) is not album or (count selection) is greater ¬
than 1 then
display dialog "Please pick one album"
else
return theAlbum
end if
on error
display dialog "Please select a photo album in iPhoto"
end try
end repeat
end tell
end getAlbum