org.qtunes.ff.spi.mp3
Class MP3Handler

java.lang.Object
  extended by org.qtunes.ff.TrackReader
      extended by org.qtunes.ff.TrackWriter
          extended by org.qtunes.ff.spi.mp3.MP3Handler
All Implemented Interfaces:
Service

public class MP3Handler
extends TrackWriter


Field Summary
 
Fields inherited from class org.qtunes.ff.TrackReader
MP3GENRES
 
Constructor Summary
MP3Handler()
           
 
Method Summary
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
          Return the AudioInputStream for the specified File.
 ServiceContext getContext()
          Return the ServiceContext that was passed into Service.startService(org.qtunes.core.ServiceContext)
 boolean getGainStorage(java.lang.String type)
           
 java.lang.String getType()
          Get the type of track read by this reader, eg "mp3".
static void main(java.lang.String[] args)
           
 boolean matches(java.io.File file)
          Return true if this TrackReader matches the File
 FieldMap read(java.io.File file)
          Load and parse the file and return a FieldMap with its fields
 java.util.Map<java.lang.String,java.lang.Object> reportState()
          Return a Map describing the state of this Service, for serialization back to any client that needs to know (eg webplayer) - so values should be serializable objects, eg Lists, Maps or simple objects.
 void setGainStorage(java.lang.String type, boolean on)
           
 void startService(ServiceContext context)
          Start the Service
 void stopService(ServiceContext context)
          Stop the Service
 boolean write(java.io.File infile, FieldMap fields)
          Update a file directly - can be used by utility classes (eg tagger package) to update files without a database.
 void write(Track track, FieldMap changes)
          Update the track
 
Methods inherited from class org.qtunes.ff.TrackReader
getTrackReader, getTrackReader, getTrackReader, getTrackReader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MP3Handler

public MP3Handler()
Method Detail

getType

public java.lang.String getType()
Description copied from class: TrackReader
Get the type of track read by this reader, eg "mp3". Must match the "Type" field of the FieldMap read by this reader

Specified by:
getType in class TrackReader

matches

public boolean matches(java.io.File file)
Description copied from class: TrackReader
Return true if this TrackReader matches the File

Specified by:
matches in class TrackReader

setGainStorage

public void setGainStorage(java.lang.String type,
                           boolean on)

getGainStorage

public boolean getGainStorage(java.lang.String type)

read

public FieldMap read(java.io.File file)
              throws java.io.IOException
Description copied from class: TrackReader
Load and parse the file and return a FieldMap with its fields

Specified by:
read in class TrackReader
Throws:
java.io.IOException

write

public void write(Track track,
                  FieldMap changes)
           throws java.io.IOException
Description copied from class: TrackWriter
Update the track

Specified by:
write in class TrackWriter
Parameters:
track - the Track with the existing fields
changes - the Changes to those fields - a value of null in this Map means the field is deleted, and a key of Field.LastModified means the File modification time will not be updated.
Throws:
java.io.IOException

write

public boolean write(java.io.File infile,
                     FieldMap fields)
              throws java.io.IOException
Description copied from class: TrackWriter
Update a file directly - can be used by utility classes (eg tagger package) to update files without a database.

Specified by:
write in class TrackWriter
Parameters:
infile - the audio File to update
fields - the Changes to those fields - a value of null in this Map means the field is deleted, and a key of Field.LastModified means the File modification time will not be updated.
Throws:
java.io.IOException

startService

public void startService(ServiceContext context)
Description copied from interface: Service
Start the Service

Parameters:
context - the ServiceContext for this Service

stopService

public void stopService(ServiceContext context)
Description copied from interface: Service
Stop the Service

Parameters:
context - the ServiceContext for this Service (same as was passed into start)

getContext

public ServiceContext getContext()
Description copied from interface: Service
Return the ServiceContext that was passed into Service.startService(org.qtunes.core.ServiceContext)


reportState

public java.util.Map<java.lang.String,java.lang.Object> reportState()
Description copied from interface: Service
Return a Map describing the state of this Service, for serialization back to any client that needs to know (eg webplayer) - so values should be serializable objects, eg Lists, Maps or simple objects. If no useful state, return null.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Description copied from class: TrackReader
Return the AudioInputStream for the specified File. We use this approach because it's more reliable than relying on the AudioSystem to correctly identify the file.

Specified by:
getAudioInputStream in class TrackReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException