![]() 3D 3D Photo Gallery (Part 1) 3D Photo Gallery (Part 2) Audio Poor Man's MIDI Make A Metronome iPod Tricks (Part 1) iPod Tricks (Part 2) iPod Tricks (Part 3) Laugh Track Machine Audio Player with Reverb Shepard Melody RB Phone Home Build a Drum Machine Custom Controls and Windows Double Click Listbox Draggable Metal Window Double Click Canvas Custom Buttons Custom Buttons Part II iTunes-style Listboxes Custom Controls General RB Scrolling Windows Using Mesage Dialogs Case-Sensitive Word Finder Introduction to Stacks Wiggle Window JPEG in PDF Listbox Checkboxes Background Applications Listbox Auto-Find Virtual Volumes Time Tracker Software Distribution (Part 1) Software Distribution (Part 2) Software Distribution (Part 3) Software Distribution (Part 4) Exceptions Tips and Tricks Text Clippings Made Easy Graphics Drawing a Simple Gradient The SpriteSurface: Space Game Image Spinner Cropping Graphics (Part 1) Cropping Graphics (Part 2) Cropping Graphics (Part 3) Cropping Graphics (Part 4) Shimmer Graphics Lissajous Figures Simple Screen Capture Vector Graphics Kaleidoscope Images Stegonography Spirals! Image Table RB Magnifying Lens Screen Capture Color Picker Tutorial Hacks Ghost Grab Speedy Mouse Extension iTunes Plugins iTunes Skinner Mac OS X Global Hot Key Event (Carbon Events) Login Welcomer (Carbon Events) Add/Remove Buttons Resizable Sheets Mac OS X Preferences Window Using Sheets in REALbasic Build a Bundle (Part 1) Build a Bundle (Part 2) Dock Your Passwords Mac OS X Debugging REALbasic Mac OS X Icon Tutorial Animate Your Dock RB and the Command Line Menus Window Menu Templates Menu Listbox Menu Novelty Guessing Game Calendar Trivia Tile Mixer Zip Code Finder Happy Valentine's Day Merlin Simulator (Part 1) Merlin Simulator (Part 2) Merlin Simulator (Part 3) Buzzword Machine AppleSoft BASIC Printing Print to PDF Registration Registration Code Validation Network Registration Codes Resources Picture Extractor (Part 1) Picture Extractor (Part 2) Serial Caller ID (Part 1) Caller ID (Part 2) Caller ID (Part 3) Speech Speech Recognition Socket Communication Easy Peer-to-Peer File Sharing MacPAD Version Checking Display Web Image In Canvas HTML IMG Tags Version Tracking Even Smarter Instant Messaging Web Tiler JavaScript and REALbasic Stock Ticker (Part I) Stock Ticker (Part 2) AIM Mate XML Manipulation Simple XML Introduction Video Big Brother Video Capture Note: All articles without a byline were written by Erick Tejkowski. When cleaning the site I removed them because the code differed from page to page, and I have yet to put them back in.
Tell us about a bad link. |
This week we'll create a simple REALbasic application that enables you to churn out custom iTunes visual plugins. Have a fun message you want to surprise a co-worker or loved one with? Try passing it along via iTunes to really get their attention. I know what you're saying.... "You can't build an iTunes plugin with REALbasic!". Fundamentally this is true. Using a few tricks, though, we can fake it. Using an existing plugin, we will replace a few items within it and build a new copy of the plugin with the revised settings, thus making a "new" plugin. The end effect is an iTunes plugin of your very own that happily draws your name in multiple colors when run. Build the Interface This week's interface is drop-dead simple to create. Launch REALbasic, open Window1 and drag an EditField, StaticText, and PushButton into the window. The EditField will be used as a place to enter your name. Pressing the PushButton will:
To give you an idea of how this might look:
Add the Code Before we jump in and start coding, you need to know a few things. First, the plugins you will create are based on a template plugin named "ResexPlugin". When installed, this plugin is a fully functioning. It displays the word "ResExcellence" in flickering colors. Further, the name of the plugin (as it appears in the iTunes menu) is "ResEx Plugin". If you do a quick count, you will see the following:
The plan is to replace these two bits of information with your own data. Since this resides within the data fork of the plugin, it is vital that you not change the length of either string. Changing them will likely render the plugin useless. Don't need all the characters? We'll fill in any blank spots with a "space", since it maintains the string lengths yet won't alter the display. The code is fairly minimal this week as well. For starters, double-click PushButton1 and enter the following code: dim src,dest as folderItemdim s,yourname,yourpluginname as string dim binin as binaryStream //find the default plugin src=GetFolderItem("ResexPlugin") if src<>nil and src.exists then dest = GetSaveFolderItem("",EditField1.text+" plugin") if dest<>nil then CopyFileOrFolder(src,dest) //we are going to change the file , so openAsBinaryFile(TRUE) binin = dest.openAsBinaryFile(TRUE) //ResExcellence = default text drawn onscreen //ResEx Plugin = default plugin name s = binin.read(binin.length+1) //add thirteen spaces to the name to be certain we //have the minimum number of characters yourname = left(Editfield1.text+" ",13) s = replaceAll(s,"ResExcellence",yourname) //the longest plugin name is 12 characters yourpluginname = left(Editfield1.text+ " Plugin ",12) s = replaceAll(s,"ResEx Plugin",yourpluginname) binin.position = 0 binin.write s binin.close end if end if If you were paying attention, you may have noticed the undefined CopyFileOrFolder call. This leads us to our last code example. Select Edit->New Method and create a new method:
You may recognize this method from the Language Reference in REALbasic. In fact, if you navigate to the "FolderItem" entry in the Language Reference, you will find the code for CopyFileOrFolder, which you can drag from into your new method. In case you like to type, the code is: Dim i as IntegerDim newFolder as FolderItem If source.directory then //it's a folder newFolder=destination.child(source.name) newFolder.createAsFolder For i=1 to source.count //go through each item If source.item(i).directory then //it's a folder CopyFileOrFolder source.item(i), newFolder //recursively call this //routine passing it the folder else source.item(i).CopyFileTo newFolder //it's a file so copy it end if next else //it's not a folder source.CopyFileTo destination end if Conclusion That's it! Test the project and when you're happy with the results, build the final application. The resulting plugin should produce somthing that looks like this:
Don't forget to keep a copy of the template plugin (entitled "ResexPlugin") in the same folder as your application. As usual, you can download the application and completed project. It also includes the C source code in case you are interested in building your own iTunes plugin in CodeWarrior. Until next week! |
|||||||||
|
Please support ResExcellence by Visiting our Sponsors. One click makes a difference. |
||||||||||
|
|