org.qtunes.ff.spi.mp4
Class MP4Handler

java.lang.Object
  extended by org.qtunes.ff.TrackReader
      extended by org.qtunes.ff.spi.mp4.MP4Handler
All Implemented Interfaces:
Service

public class MP4Handler
extends TrackReader

A parser to load MP4 objects. Doesn't decode audio, but can extract metadata from the MP4 object. Uses NIO and skips over blocks that aren't required so should be very quick and memory efficient.


Field Summary
 
Fields inherited from class org.qtunes.ff.TrackReader
MP3GENRES
 
Constructor Summary
MP4Handler()
           
 
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)
 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 startService(ServiceContext context)
          Start the Service
 void stopService(ServiceContext context)
          Stop the Service
 
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

MP4Handler

public MP4Handler()
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

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

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.


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)


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