TvRecordingClient


public class TvRecordingClient
extends Object

java.lang.Object
   ↳ android.media.tv.TvRecordingClient


The public interface object used to interact with a specific TV input service for TV program recording.

Summary

Nested classes

class TvRecordingClient.RecordingCallback

Callback used to receive various status updates on the TvInputService.RecordingSession 

Public constructors

TvRecordingClient(Context context, String tag, TvRecordingClient.RecordingCallback callback, Handler handler)

Creates a new TvRecordingClient object.

Public methods

void pauseRecording()

Pause TV program recording in the current recording session.

void pauseRecording(Bundle params)

Pause TV program recording in the current recording session.

void release()

Releases the resources in the current recording session immediately.

void resumeRecording()

Resume TV program recording only in recording pause status in the current recording session.

void resumeRecording(Bundle params)

Resume TV program recording only in recording pause status in the current recording session.

void sendAppPrivateCommand(String action, Bundle data)

Sends a private command to the underlying TV input.

void setTvInteractiveAppView(TvInteractiveAppView view, String recordingId)

Sets the related TvInteractiveAppView instance so the interactive app service can be notified for recording events.

void startRecording(Uri programUri, Bundle params)

Starts TV program recording in the current recording session.

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, Bundle params)

Tunes to a given channel for TV program recording.

void tune(String inputId, Uri channelUri)

Tunes to a given channel for TV program recording.

Inherited methods

Public constructors

TvRecordingClient

Added in API level 24
public TvRecordingClient (Context context, 
                String tag, 
                TvRecordingClient.RecordingCallback callback, 
                Handler handler)

Creates a new TvRecordingClient object.

Parameters
context Context: The application context to create a TvRecordingClient with.

tag String: A short name for debugging purposes.

callback TvRecordingClient.RecordingCallback: The callback to receive recording status changes. This value cannot be null.

handler Handler: The handler to invoke the callback on.

Public methods

pauseRecording

Added in API level 31
public void pauseRecording ()

Pause TV program recording in the current recording session. Recording is expected to pause immediately when this method is called. If recording has not yet started in the current recording session, this method does nothing.

In pause status, the application can tune during recording. To continue recording, please call TvRecordingClient#resumeRecording() to resume instead of TvRecordingClient#startRecording(Uri). Application can stop the recording with TvRecordingClient#stopRecording() in recording pause status.

If the pause request cannot be fulfilled, the recording session will respond by calling RecordingCallback#onError(int).

pauseRecording

Added in API level 31
public void pauseRecording (Bundle params)

Pause TV program recording in the current recording session. Recording is expected to pause immediately when this method is called. If recording has not yet started in the current recording session, this method does nothing.

In pause status, the application can tune during recording. To continue recording, please call TvRecordingClient#resumeRecording() to resume instead of TvRecordingClient#startRecording(Uri). Application can stop the recording with TvRecordingClient#stopRecording() in recording pause status.

If the pause request cannot be fulfilled, the recording session will respond by calling RecordingCallback#onError(int).

Parameters
params Bundle: Domain-specific data for this request. This value cannot be null.

release

Added in API level 24
public void release ()

Releases the resources in the current recording session immediately. This may be called at any time, however if the session is already released, it does nothing.

resumeRecording

Added in API level 31
public void resumeRecording ()

Resume TV program recording only in recording pause status in the current recording session. Recording is expected to resume immediately when this method is called. If recording has not yet paused in the current recording session, this method does nothing.

When record is resumed, the recording is continue and can not re-tune. Application can stop the recording with TvRecordingClient#stopRecording() after record resumed.

If the pause request cannot be fulfilled, the recording session will respond by calling RecordingCallback#onError(int).

resumeRecording

Added in API level 31
public void resumeRecording (Bundle params)

Resume TV program recording only in recording pause status in the current recording session. Recording is expected to resume immediately when this method is called. If recording has not yet paused in the current recording session, this method does nothing.

When record is resumed, the recording is continues and can not re-tune. Application can stop the recording with TvRecordingClient#stopRecording() after record resumed.

If the resume request cannot be fulfilled, the recording session will respond by calling RecordingCallback#onError(int).

Parameters
params Bundle: Domain-specific data for this request. This value cannot be null.

sendAppPrivateCommand

Added in API level 24
public void sendAppPrivateCommand (String action, 
                Bundle data)

Sends a private command to the underlying TV input. This can be used to provide domain-specific features that are only known between certain clients and their TV inputs.

Parameters
action String: 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. This value cannot be null.

data Bundle: An optional bundle to send with the command.

setTvInteractiveAppView

Added in API level 34
public void setTvInteractiveAppView (TvInteractiveAppView view, 
                String recordingId)

Sets the related TvInteractiveAppView instance so the interactive app service can be notified for recording events.

Parameters
view TvInteractiveAppView: The related TvInteractiveAppView instance that is linked to this TV recording client. null to unlink the view.

recordingId String: The ID of the recording which is assigned by the TV application. null if and only if the TvInteractiveAppView parameter is null.

Throws
IllegalArgumentException when recording ID is null and the TvInteractiveAppView is not null; or when recording ID is not null and the TvInteractiveAppView is null.

startRecording

Added in API level 30
public void startRecording (Uri programUri, 
                Bundle params)

Starts TV program recording in the current recording session. Recording is expected to start immediately when this method is called. If the current recording session has not yet tuned to any channel, this method throws an exception.

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 TvRecordingClient#stopRecording() to stop the recording.

The recording session will respond by calling RecordingCallback#onError(int) if the start request cannot be fulfilled.

Parameters
programUri Uri: The URI for the TV program to record, built by TvContract#buildProgramUri(long). Can be null.

params Bundle: Domain-specific data for this 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. This value cannot be null.

Throws
IllegalStateException If tune(String, Uri) request hasn't been handled yet or during pause.

startRecording

Added in API level 24
public void startRecording (Uri programUri)

Starts TV program recording in the current recording session. Recording is expected to start immediately when this method is called. If the current recording session has not yet tuned to any channel, this method throws an exception.

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 TvRecordingClient#stopRecording() to stop the recording.

The recording session will respond by calling RecordingCallback#onError(int) if the start request cannot be fulfilled.

Parameters
programUri Uri: The URI for the TV program to record, built by TvContract#buildProgramUri(long). Can be null.

Throws
IllegalStateException If tune(String, Uri) request hasn't been handled yet or during pause.

stopRecording

Added in API level 24
public void stopRecording ()

Stops TV program recording in the current recording session. Recording is expected to stop immediately when this method is called. If recording has not yet started in the current recording session, this method does nothing.

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 RecordingCallback#onRecordingStopped(Uri). If the stop request cannot be fulfilled, the recording session will respond by calling RecordingCallback#onError(int).

tune

Added in API level 24
public void tune (String inputId, 
                Uri channelUri, 
                Bundle params)

Tunes to a given channel for TV program recording. The first tune request will create a new recording session for the corresponding TV input and establish a connection between the application and the session. If recording has already started in the current recording session, this method throws an exception. This can be used to provide domain-specific features that are only known between certain client and their TV inputs.

The application may call this method before starting or after stopping recording, but not during recording.

The recording session will respond by calling RecordingCallback#onTuned(Uri) if the tune request was fulfilled, or RecordingCallback#onError(int) otherwise.

Parameters
inputId String: The ID of the TV input for the given channel.

channelUri Uri: The URI of a channel.

params Bundle: 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.

Throws
IllegalStateException If recording is already started.

tune

Added in API level 24
public void tune (String inputId, 
                Uri channelUri)

Tunes to a given channel for TV program recording. The first tune request will create a new recording session for the corresponding TV input and establish a connection between the application and the session. If recording has already started in the current recording session, this method throws an exception.

The application may call this method before starting or after stopping recording, but not during recording.

The recording session will respond by calling RecordingCallback#onTuned(Uri) if the tune request was fulfilled, or RecordingCallback#onError(int) otherwise.

Parameters
inputId String: The ID of the TV input for the given channel.

channelUri Uri: The URI of a channel.

Throws
IllegalStateException If recording is already started.