On Jul 8, 2006, at 10:37 AM, William Squires wrote:
Hi!
I need to:
1) Present a dialog that asks the user to insert a particular CD.
Easy enough, but how do I actually 'wait' until the CD in question
(or any CD, for that matter) is inserted (MacOS X only, though it'd
be nice if there were an x-platform - Win/Linux - way of doing it.)
2) check the CD (an audio CD - no copy protection on it) to see if
it's the one I'm looking for.
Reason: I'm trying to make a program that goes along with the early
"Advanced Dungeons & Dragons. Karameikos: Land of Adventure" boxed
set. It includes an audio CD with tracks that are played at
specific points in the game.
In order to avoid copyright violation, I want to import the
tracks (as WAVs), and require the user to have bought the 'real' CD
(thus the 'check the CD' dialog above.)
Is there some unique feature (maybe a 'key' that's used for the
CDDB lookup in iTunes?) of audio CDs that I can look for?
Can I make a FolderItem to represent the CD volume, then iterate
over it to get the tracks, or is that just a Finder trick?
1) is simple. Create a dialog window CDPrompt. Drop a Timer on it
that scans the FolderItems returned by Volume for a CD. Set its mode
to multiple and the period to something like 1000. When a CD is
found, close the dialog. Here's the code from my test.
Sub Action()
For i as Integer = 0 to VolumeCount - 1
If Volume(i).Name = "Comfort of Strangers" then
self.Close
Exit
End if
Next
End Sub
You can also add a Cancel button to the dialog.
Call CDPrompt.ShowModal from the appropriate location. Then check
for the CD and proceed.
I think that it's possible on MacOS, at least, to decide whether a
volume is a CD. But perhaps you could try a simpler approach --
Function MightBeAudioCD( f as FolderItem) as Boolean
If f is nil then
Return false
End if
dim theVolume as FolderItem = f
While theVolume.Parent <> nil
theVolume = theVolume.Parent
Wend
If theVolume.IsWriteable or not theVolume.Locked then
Return false
End if
//you could next look for audio files at the root level of the volume
Return true
End Function
As as last resort, you could prompt the user to select the tracks to
import.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>