FileDocCategorySizeDatePackage
ID3TagReader.javaAPI DocExample3635Wed Nov 10 12:38:32 GMT 2004com.oreilly.qtjnotebook.ch07

ID3TagReader

public class ID3TagReader extends Object

Fields Summary
static final int
kUserDataTextAlbum
static final int
kUserDataTextArtist
static final int
kUserDataTextCreationDate
static final int
kUserDataTextFullName
private static final Object[]
TAG_NAMES
private static final HashMap
TAG_MAP
Constructors Summary
public ID3TagReader()

        try {
            QTSessionCheck.check();
            QTFile f = QTFile.standardGetFilePreview (null);
            OpenMovieFile omf = OpenMovieFile.asRead(f);
            Movie movie = Movie.fromFile (omf);
            // get user data
            UserData userData = movie.getUserData();
            dumpTagsFromUserData(userData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    
Methods Summary
protected static voiddumpTagsFromUserData(UserData userData)

        // try for each key in TAG_MAP
        Iterator it = TAG_MAP.keySet().iterator();
        while (it.hasNext()) {
            Integer key = (Integer) it.next();
            int tag = key.intValue();
            String tagName = (String) TAG_MAP.get(key);
            try {
                String value =
                    userData.getTextAsString (tag,
                                              1,
                                              IOConstants.langUnspecified);
                System.out.println (tagName + ": " + value);
            } catch (QTException qte) {} // no such tag
        }
    
public static voidmain(java.lang.String[] args)

     
        for (int i=0; i<TAG_NAMES.length; i++) {
            TAG_MAP.put (TAG_NAMES[i][0],
                         TAG_NAMES[i][1]);
        }
    
        new ID3TagReader();
        System.exit(0);