Package ptolemy.actor.lib.jmf
Class MovieReader
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,javax.media.ControllerListener
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class MovieReader extends Source implements javax.media.ControllerListener
This actor loads a video file (MPEG, AVI, or Quicktime files only), and outputs each frame as a JMFImageToken.Note that not all formats are supported, for details, see the JMF faq at: http://www.oracle.com/technetwork/java/javase/faq-jmf-137005.html#jmf2-support.
- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- James Yeh
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description FileParameter
fileOrURL
The file name or URL from which to read.-
Fields inherited from class ptolemy.actor.lib.Source
_triggered, output, trigger
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description MovieReader(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_waitForState(int state)
Block until the processor has transitioned to the given state.void
attributeChanged(Attribute attribute)
An attempt is made to acquire the file name.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
controllerUpdate(javax.media.ControllerEvent event)
The controller listener.void
fire()
Send a JMFImageToken out through the output port.void
initialize()
An attempt is made to acquire both the frame grabbing and frame positioning controls.boolean
postfire()
If the player is no longer open, then disconnect the datasource.-
Methods inherited from class ptolemy.actor.lib.Source
_customTypeConstraints, prefire
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
fileOrURL
public FileParameter fileOrURL
The file name or URL from which to read. This is a string with any form accepted by File Attribute. The default value is the string "file:///C:/program%20files/quicktime/Sample.mov".- See Also:
FileParameter
-
-
Constructor Detail
-
MovieReader
public MovieReader(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
An attempt is made to acquire the file name. If it is successful, create the DataSource that encapsulates the file.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the URL is null, or invalid.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new attribute- Returns:
- A new director.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
controllerUpdate
public void controllerUpdate(javax.media.ControllerEvent event)
The controller listener. This method controls the initializing of the player. It also senses when the file is done playing, in which case it closes the player.- Specified by:
controllerUpdate
in interfacejavax.media.ControllerListener
- Parameters:
event
- The controller event.
-
fire
public void fire() throws IllegalActionException
Send a JMFImageToken out through the output port.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classSource
- Throws:
IllegalActionException
- If there's no director.
-
initialize
public void initialize() throws IllegalActionException
An attempt is made to acquire both the frame grabbing and frame positioning controls. If both succeed, the first frame is acquired.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the either frame grabbing control or frame positioning control cannot be acquired, or if a contained method throws it.
-
postfire
public boolean postfire() throws IllegalActionException
If the player is no longer open, then disconnect the datasource. If the player is still open, acquire the next frame.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- false if the player is no longer open, otherwise return super.postfire().
- Throws:
IllegalActionException
- If thrown by the super class.
-
_waitForState
protected boolean _waitForState(int state) throws IllegalActionException
Block until the processor has transitioned to the given state.- Parameters:
state
- The state.- Returns:
- false if the transition failed.
- Throws:
IllegalActionException
- If there is a problem blocking the processor until the state transition is completed.
-
-