javax.microedition.media.control
Interface RecordControl

All Superinterfaces:
Control

public interface RecordControl
extends Control

RecordControl controls the recording of media from a Player. RecordControl records what's currently being played by the Player.

Example

    try {
        // Create a Player that captures live audio.
        Player p = Manager.createPlayer("capture://audio");
        p.realize();
       // Get the RecordControl, set the record stream,
       // start the Player and record for 5 seconds.
       RecordControl rc = (RecordControl)p.getControl("RecordControl");
       ByteArrayOutputStream output = new ByteArrayOutputStream();
       rc.setRecordStream(output);
       rc.startRecord();
       p.start();
       Thread.currentThread().sleep(5000);
       rc.commit();
       p.close();
    } catch (IOException ioe) {
    } catch (MediaException me) {
    } catch (InterruptedException ie) {}
 

See Also:
Player
Since:
BlackBerry API 4.0.0

Method Summary
 void commit()
          Complete the current recording.
 String getContentType()
          Return the content type of the recorded media.
 void reset()
          Erase the current recording.
 void setRecordLocation(String locator)
          Set the output location where the data will be recorded.
 int setRecordSizeLimit(int size)
          Set the record size limit.
 void setRecordStream(OutputStream stream)
          Set the output stream where the data will be recorded.
 void startRecord()
          Start recording the media.
 void stopRecord()
          Stop recording the media, stopRecord will not automatically stop the Player.
 



Method Detail

setRecordStream

void setRecordStream(OutputStream stream)
Set the output stream where the data will be recorded.

Whenever possible, the recording format is the same as the format of the input media. In some cases, the recording format may be different from the input format if the input format is not a recordable format, e.g. streaming media data. An application can query the recorded format by calling the getContentType method.

Parameters:
stream - The output stream where the data will be recorded.
Throws:
IllegalStateException - Thrown if one of the following conditions is true:
  • startRecord has been called and commit has not been called.
  • setRecordLocation has been called and commit has not been called.
IllegalArgumentException - Thrown if stream is null.
SecurityException - Thrown if the caller does not have security permission to set the record stream.
Since:
BlackBerry API 4.0.0

setRecordLocation

void setRecordLocation(String locator)
                       throws IOException,
                              MediaException
Set the output location where the data will be recorded.

Whenever possible, the recording format is the same as the format of the input media. In some cases, the recording format may be different from the input format if the input format is not a recordable format, e.g. streaming media data. An application can query the recorded format by calling the getContentType method.

Parameters:
locator - The locator specifying where the recorded media will be saved. The locator must be specified as a URL.
Throws:
IllegalStateException - Thrown if one of the following conditions is true:
  • startRecord has been called and commit has not been called.
  • setRecordStream has been called and commit has not been called.
IllegalArgumentException - Thrown if locator is null.
IOException - Thrown if protocol is valid but the media cannot be created at the specified location.
MediaException - Thrown if the locator is not in URL syntax or it specifies a protocol that is not supported.
SecurityException - Thrown if the caller does not have security permission to set the record location.
Since:
BlackBerry API 4.0.0

getContentType

String getContentType()
Return the content type of the recorded media. The content type is given in the content type syntax.

Returns:
The content type of the media.
Since:
BlackBerry API 4.0.0

startRecord

void startRecord()
Start recording the media.

If the Player is already started, startRecord will immediately start the recording. If the Player is not already started, startRecord will not record any media. It will put the recording in a "standby" mode. As soon as the Player is started, the recording will start right away.

If startRecord is called when the recording has already started, it will be ignored.

When startRecord returns, the recording has started and a RECORD_STARTED event will be delivered through the PlayerListener.

If an error occurs while recording is in progress, RECORD_ERROR event will be delivered via the PlayerListener.

Throws:
IllegalStateException - Thrown if one of the following conditions is true:
  • setRecordLocation or setRecordStream has not been called for the first time.
  • If commit has been called and setRecordLocation or setRecordStream has not been called.
MediaException - Thrown if unable to start recording (possibly because required resource such as a recording session is not available)
Since:
BlackBerry API 4.0.0

stopRecord

void stopRecord()
Stop recording the media, stopRecord will not automatically stop the Player. It only stops the recording.

Stopping the Player does not imply a stopRecord. Rather, the recording will be put into a "standby" mode. Once the Player is re-started, the recording will resume automatically.

After stopRecord, startRecord can be called to resume the recording.

If stopRecord is called when the recording has already stopped, it will be ignored.

When stopRecord returns, the recording has stopped and a RECORD_STOPPED event will be delivered through the PlayerListener.

Since:
BlackBerry API 4.0.0

commit

void commit()
            throws IOException
Complete the current recording.

If the recording is in progress, commit will implicitly call stopRecord.

To record again after commit has been called, setRecordLocation or setRecordStream must be called.

Throws:
IOException - Thrown if an I/O error occurs during commit. The current recording is not valid. To record again, setRecordLocation or setRecordStream must be called.
Since:
BlackBerry API 4.0.0

setRecordSizeLimit

int setRecordSizeLimit(int size)
                       throws MediaException
Set the record size limit. This limits the size of the recorded media to the number of bytes specified.

When recording is in progress, commit will be called implicitly in the following cases:

Once a record size limit has been set, it will remain so for future recordings until it is changed by another setRecordSizeLimit call.

To remove the record size limit, set it to Integer.MAX_VALUE. By default, the record size limit is not set.

Only positive values can be set. Zero or negative values are invalid and an IllegalArgumentException will be thrown.

Parameters:
size - The record size limit in number of bytes.
Returns:
The actual size limit set.
Throws:
IllegalArgumentException - Thrown if the given size is invalid.
MediaException - Thrown if setting the record size limit is not supported.
Since:
BlackBerry API 4.0.0

reset

void reset()
           throws IOException
Erase the current recording.

If the recording is in progress, reset will implicitly call stopRecord.

Calling reset after commit will have no effect on the current recording.

If the Player that is associated with this RecordControl is closed, reset will be called implicitly.

Throws:
IOException - Thrown if the current recording cannot be erased. The current recording is not valid. To record again, setRecordLocation or setRecordStream must be called.
Since:
BlackBerry API 4.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.