public class TvRecordingClient extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TvRecordingClient.RecordingCallback
Callback used to receive various status updates on the
TvInputService.RecordingSession |
Constructor and Description |
---|
TvRecordingClient(Context context,
String tag,
TvRecordingClient.RecordingCallback callback,
Handler handler)
Creates a new TvRecordingClient object.
|
Modifier and Type | Method and Description |
---|---|
void |
release()
Releases the resources in the current recording session immediately.
|
void |
sendAppPrivateCommand(String action,
Bundle data)
Sends a private command to the underlying TV input.
|
void |
startRecording(Uri programUri)
Starts TV program recording in the current recording session.
|
void |
stopRecording()
Stops TV program recording in the current recording session.
|
void |
tune(String inputId,
Uri channelUri)
Tunes to a given channel for TV program recording.
|
void |
tune(String inputId,
Uri channelUri,
Bundle params)
Tunes to a given channel for TV program recording.
|
public TvRecordingClient(Context context, String tag, TvRecordingClient.RecordingCallback callback, Handler handler)
context
- The application context to create a TvRecordingClient with.tag
- A short name for debugging purposes.callback
- The callback to receive recording status changes.handler
- The handler to invoke the callback on.public void tune(String inputId, Uri channelUri)
The application may call this method before starting or after stopping recording, but not during recording.
The recording session will respond by calling
TvRecordingClient.RecordingCallback.onTuned(Uri)
if the tune request was fulfilled, or
TvRecordingClient.RecordingCallback.onError(int)
otherwise.
inputId
- The ID of the TV input for the given channel.channelUri
- The URI of a channel.IllegalStateException
- If recording is already started.public void tune(String inputId, Uri channelUri, Bundle params)
The application may call this method before starting or after stopping recording, but not during recording.
The recording session will respond by calling
TvRecordingClient.RecordingCallback.onTuned(Uri)
if the tune request was fulfilled, or
TvRecordingClient.RecordingCallback.onError(int)
otherwise.
inputId
- The ID of the TV input for the given channel.channelUri
- The URI of a channel.params
- Domain-specific data for this tune request. Keys must be a scoped
name, i.e. prefixed with a package name you own, so that different developers will
not create conflicting keys.IllegalStateException
- If recording is already started.public void release()
public void startRecording(Uri programUri)
The application may supply the URI for a TV program for filling in program specific data
fields in the TvContract.RecordedPrograms
table.
A non-null programUri
implies the started recording should be of that specific
program, whereas null programUri
does not impose such a requirement and the
recording can span across multiple TV programs. In either case, the application must call
stopRecording()
to stop the recording.
The recording session will respond by calling TvRecordingClient.RecordingCallback.onError(int)
if
the start request cannot be fulfilled.
programUri
- The URI for the TV program to record, built by
TvContract.buildProgramUri(long)
. Can be null
.IllegalStateException
- If tune(java.lang.String, android.net.Uri)
request hasn't been handled yet.public void stopRecording()
The recording session is expected to create a new data entry in the
TvContract.RecordedPrograms
table that describes the newly
recorded program and pass the URI to that entry through to
TvRecordingClient.RecordingCallback.onRecordingStopped(Uri)
.
If the stop request cannot be fulfilled, the recording session will respond by calling
TvRecordingClient.RecordingCallback.onError(int)
.
public void sendAppPrivateCommand(String action, Bundle data)
action
- The name of the private command to send. This must be a scoped name,
i.e. prefixed with a package name you own, so that different developers will not
create conflicting commands.data
- An optional bundle to send with the command.