|
1.0: Final Release | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
SnapshotControl
controls burst shooting with the camera.
With this Control
, it is possible to shoot multiple pictures
with one method call in an efficient way.
SnapshotControl
stores the captured pictures in the file system. Initially, before
any setDirectory
method calls the storage directory is pointing to the default image store
location of the implementing platform. That directory can be queried by getDirectory
before setting a new directory.
Images will be stored in the files system only if the application has rights to create files to the
given directory. Rights are checked when the setDirectory
method is called but it is possible
that the rights are changed after that. In that case, a STORAGE_ERROR
event will be posted if
the application has no file creation rights when an attempt is made to store the captured image
in the file system.
The structure of the generated file name is
<prefix><auto generated string><suffix>
where
prefix
is a user given prefix String
.
auto generated string
is a String
generated automatically by the implementation.
The generated String
is a zero padded four digit running number starting from 0.
Therefore, the sequence of generated
String
s is "0000", "0001", "0002" etc. The length of the String
increases if more digits are needed
to represent the number so "9999" will be followed by "10000".
suffix
is a user given suffix String
.
File name generation runs through the lifetime of the Player
. In other words, it is not
necessary to set the prefix before each call of the start
method. Notice that it is likely that
the naming method defined here differs from the naming system of the native imaging applications of
the device.
If the directory, where the files are stored, contains a file with the same name as the generated image file, the generated image file will not be written anywhere. A STORAGE_ERROR message with a the name of the file, whose writing failed, will be sent and capturing of the images will stop.
Field Summary | |
static int |
FREEZE
Takes one snapshot, freezes the viewfinder, and unfreezes it again after some time. |
static int |
FREEZE_AND_CONFIRM
Freezes the viewfinder and keeps it frozen until unfreeze is called. |
static java.lang.String |
SHOOTING_STOPPED
Posted to PlayerListener when the burst shooting stops
and the files have been stored into the file system. |
static java.lang.String |
STORAGE_ERROR
Posted to PlayerListener when there has been
an error while storing the files into the file system. |
static java.lang.String |
WAITING_UNFREEZE
Posted to PlayerListener when
shooting has been started as FREEZE_AND_CONFIRM . |
Method Summary | |
java.lang.String |
getDirectory()
Gets the storage directory. |
java.lang.String |
getFilePrefix()
Gets the filename prefix. |
java.lang.String |
getFileSuffix()
Gets the filename suffix. |
void |
setDirectory(java.lang.String directory)
Sets the file directory where the images will be stored. |
void |
setFilePrefix(java.lang.String prefix)
Sets the filename prefix. |
void |
setFileSuffix(java.lang.String suffix)
Sets the filename suffix. |
void |
start(int maxShots)
Starts burst shooting. |
void |
stop()
Stops burst shooting. |
void |
unfreeze(boolean save)
Unfreezes the viewfinder and saves the snapshot depending on the parameter. |
Field Detail |
public static final java.lang.String SHOOTING_STOPPED
PlayerListener
when the burst shooting stops
and the files have been stored into the file system.
When this event is received, the eventData
parameter
is a String
containing the name of the last generated file.
Value SHOOTING_STOPPED
is assigned to
SHOOTING_STOPPED
.
public static final java.lang.String STORAGE_ERROR
PlayerListener
when there has been
an error while storing the files into the file system. Shooting of the images
is stopped but SHOOTING_STOPPED event will not be posted.
When this event is received, the eventData
parameter
is a String
containing the name of the file whose writing failed.
Value STORAGE_ERROR
is assigned to
STORAGE_ERROR
.
public static final java.lang.String WAITING_UNFREEZE
PlayerListener
when
shooting has been started as FREEZE_AND_CONFIRM
.
At this point, the implementation is waiting that
unfreeze
will be called.
If the application is waiting for the user to choose whether the
picture should be saved or not, the query should be done
in a separate thread and this method should return as quickly
as possible.
When this event is received, the eventData
parameter
will be null.
Value WAITING_UNFREEZE
is assigned to
WAITING_UNFREEZE
.
public static final int FREEZE
public static final int FREEZE_AND_CONFIRM
unfreeze
is called.
Takes a snapshot depending on the parameter of the unfreeze
method.
unfreeze(boolean)
,
Constant Field ValuesMethod Detail |
public void setDirectory(java.lang.String directory)
The directory name is given as a String which can contain the trailing slash "/" in the directory name but it is not required.
For example, both
"/SDCard/"
and "/SDCard"
set the directory to the root of the SDCard in a platform
implementing FileConnection
of JSR-75.
In case of FileConnection
of JSR-75 the return
value of FileConnection.getPath()
can be used
as it is as a parameter for this method.
directory
- the storage directory
java.lang.IllegalArgumentException
- if the given directory does not exist or it is null
java.lang.SecurityException
- if the creation of files to the given location is not allowedpublic java.lang.String getDirectory()
setDirectory
has not been called the directory
points to the default image storing location.
public void setFilePrefix(java.lang.String prefix)
prefix
- the prefix String for the files to be created
java.lang.IllegalArgumentException
- if the given prefix cannot be set or if it is nullpublic java.lang.String getFilePrefix()
public void setFileSuffix(java.lang.String suffix)
java.lang.IllegalArgumentException
- if the given suffix cannot be set or if it is nullpublic java.lang.String getFileSuffix()
public void start(int maxShots) throws java.lang.SecurityException
maxShots
- the maximum number of shots that are going to be taken
or FREEZE or FREEZE_AND_CONFIRM. Integer.MAX_VALUE
will take as many shots as possible.
java.lang.IllegalArgumentException
- if maxShots is less than one
java.lang.IllegalStateException
- if prefix and suffix have not been set
java.lang.SecurityException
- if the application does not have permission to take snapshotspublic void stop()
public void unfreeze(boolean save)
start(FREEZE_AND_CONFIRM)
has not been called.
save
- true
to save the snapshot,
false
not to save the snapshot
|
1.0: Final Release | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |