# TvInputService.Session

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Session

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/tv/TvInputService.Session "View this page in Java")  

```
abstract class Session : KeyEvent.Callback
```

|---|------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                     ||
| ↳ | [android.media.tv.TvInputService.Session](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#) |

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [TvInputService.HardwareSession](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.HardwareSession) |----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| | [TvInputService.HardwareSession](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.HardwareSession) | Base class for a TV input session which represents an external device connected to a hardware TV input. | |

Base class for derived classes to implement to provide a TV input session.

## Summary

|                                                                                                                          Public constructors                                                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Session](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#Session(android.content.Context))`(`context:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!`)` Creates a new Session. |

|                                                                                                                                                                                                                                                                                                                                                                                                           Public methods                                                                                                                                                                                                                                                                                                                                                                                                           ||
|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [layoutSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#layoutSurface(kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`left:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `top:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `right:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `bottom:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Assigns a size and position to the surface passed in[onSetSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)). |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyAdBufferConsumed](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAdBufferConsumed(android.media.tv.AdBuffer))`(`buffer:` `[AdBuffer](https://developer.android.com/reference/kotlin/android/media/tv/AdBuffer)`)` Notifies the advertisement buffer is consumed.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyAdResponse](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAdResponse(android.media.tv.AdResponse))`(`response:` `[AdResponse](https://developer.android.com/reference/kotlin/android/media/tv/AdResponse)`)` Notifies response for advertisement.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyAitInfoUpdated](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAitInfoUpdated(android.media.tv.AitInfo))`(`aitInfo:` `[AitInfo](https://developer.android.com/reference/kotlin/android/media/tv/AitInfo)`)` Informs the app that the AIT (Application Information Table) is updated.                                                                                                                                                                                                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyAudioPresentationChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAudioPresentationChanged(kotlin.collections.MutableList))`(`audioPresentations:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[AudioPresentation](https://developer.android.com/reference/kotlin/android/media/AudioPresentation.html#)!>`)` Sends an updated list of all audio presentations available from a Next Generation Audio service.                                                                                                                                                                                                |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyAudioPresentationSelected](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAudioPresentationSelected(kotlin.Int,%20kotlin.Int))`(`presentationId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `programId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sends the presentation and program IDs of the selected audio presentation.                                                                                                                                                                                                                                                                            |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyAvailableSpeeds](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAvailableSpeeds(kotlin.FloatArray))`(`speeds:` `[FloatArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float-array/index.html)`)` Informs the app available speeds for time-shifting.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyBroadcastInfoResponse](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyBroadcastInfoResponse(android.media.tv.BroadcastInfoResponse))`(`response:` `[BroadcastInfoResponse](https://developer.android.com/reference/kotlin/android/media/tv/BroadcastInfoResponse)`)` Notifies response for broadcast info.                                                                                                                                                                                                                                                                                                                                                                        |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyChannelRetuned](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyChannelRetuned(android.net.Uri))`(`channelUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!`)` Informs the application that the current channel is re-tuned for some reason and the session now displays the content from a new channel.                                                                                                                                                                                                                                                                                                                                         |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyContentAllowed](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyContentAllowed())`()` Informs the application that the user is allowed to watch the current program content.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyContentBlocked](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyContentBlocked(android.media.tv.TvContentRating))`(`rating:` `[TvContentRating](https://developer.android.com/reference/kotlin/android/media/tv/TvContentRating)`)` Informs the application that the current program content is blocked by parent controls.                                                                                                                                                                                                                                                                                                                                                        |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyCueingMessageAvailability](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyCueingMessageAvailability(kotlin.Boolean))`(`available:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Informs the application that cueing message is available or unavailable.                                                                                                                                                                                                                                                                                                                                                                                |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifySignalStrength](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifySignalStrength(kotlin.Int))`(`strength:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Notifies signal strength.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyTimeShiftMode](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTimeShiftMode(kotlin.Int))`(`mode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Informs the app that the time shift mode is set or updated.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyTimeShiftStatusChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTimeShiftStatusChanged(kotlin.Int))`(`status:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Informs the application that the time shift status is changed.                                                                                                                                                                                                                                                                                                                                                                                                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyTrackSelected](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTrackSelected(kotlin.Int,%20kotlin.String))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `trackId:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Sends the type and ID of a selected track.                                                                                                                                                                                                                                                                                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyTracksChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTracksChanged(kotlin.collections.MutableList))`(`tracks:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[TvTrackInfo](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo)!>!`)` Sends the list of all audio/video/subtitle tracks.                                                                                                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyTuned](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTuned(android.net.Uri))`(`channelUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)`)` Informs the application that this session has been tuned to the given channel.                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyTvMessage](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTvMessage(kotlin.Int,%20android.os.Bundle))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `data:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Sends the raw data from the received TV message as well as the type of message received.                                                                                                                                                                                                                                                                                                |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyVideoAvailable](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoAvailable())`()` Informs the application that the video is now available for watching.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyVideoFreezeUpdated](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoFreezeUpdated(kotlin.Boolean))`(`isFrozen:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Informs the application that the video freeze state has been updated.                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [notifyVideoUnavailable](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoUnavailable(kotlin.Int))`(`reason:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Informs the application that the video became unavailable for some reason.                                                                                                                                                                                                                                                                                                                                                                                                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onAdBufferReady](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onAdBufferReady(android.media.tv.AdBuffer))`(`buffer:` `[AdBuffer](https://developer.android.com/reference/kotlin/android/media/tv/AdBuffer)`)` Called when an advertisement buffer is ready for playback.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onAppPrivateCommand](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onAppPrivateCommand(kotlin.String,%20android.os.Bundle))`(`action:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `data:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Processes a private command sent from the application to the TV input.                                                                                                                                                                                                                                                                                              |
| open[View](https://developer.android.com/reference/kotlin/android/view/View.html#)!        | [onCreateOverlayView](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onCreateOverlayView())`()` Called when the application requests to create an overlay view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onGenericMotionEvent](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onGenericMotionEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!`)` Implement this method to handle generic motion events on the current input session.                                                                                                                                                                                                                                                                                                                                                                          |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onKeyDown](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onKeyDown(kotlin.Int,%20android.view.KeyEvent))`(`keyCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!`)` Default implementation of[KeyEvent.Callback.onKeyDown()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyDown(kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                                        |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onKeyLongPress](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onKeyLongPress(kotlin.Int,%20android.view.KeyEvent))`(`keyCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!`)` Default implementation of[KeyEvent.Callback.onKeyLongPress()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyLongPress(kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                    |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onKeyMultiple](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onKeyMultiple(kotlin.Int,%20kotlin.Int,%20android.view.KeyEvent))`(`keyCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `count:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!`)` Default implementation of[KeyEvent.Callback.onKeyMultiple()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyMultiple(kotlin.Int,%20kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).     |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onKeyUp](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onKeyUp(kotlin.Int,%20android.view.KeyEvent))`(`keyCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `event:` `[KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!`)` Default implementation of[KeyEvent.Callback.onKeyUp()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyUp(kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).                                                                                                                                                |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onOverlayViewSizeChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onOverlayViewSizeChanged(kotlin.Int,%20kotlin.Int))`(`width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the size of the overlay view is changed by the application.                                                                                                                                                                                                                                                                                                         |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [onRelease](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onRelease())`()` Called when the session is released.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onRemoveBroadcastInfo](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onRemoveBroadcastInfo(kotlin.Int))`(`requestId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when broadcast info is removed.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onRequestAd](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onRequestAd(android.media.tv.AdRequest))`(`request:` `[AdRequest](https://developer.android.com/reference/kotlin/android/media/tv/AdRequest)`)` Called when advertisement request is received.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onRequestBroadcastInfo](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onRequestBroadcastInfo(android.media.tv.BroadcastInfoRequest))`(`request:` `[BroadcastInfoRequest](https://developer.android.com/reference/kotlin/android/media/tv/BroadcastInfoRequest)`)` Called when broadcast info is requested.                                                                                                                                                                                                                                                                                                                                                                                   |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onResumePlayback](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onResumePlayback())`()` Resumes playback of the Audio, Video, and CC streams.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onSelectAudioPresentation](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSelectAudioPresentation(kotlin.Int,%20kotlin.Int))`(`presentationId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `programId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Selects an audio presentation.                                                                                                                                                                                                                                                                                                                                    |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onSelectTrack](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSelectTrack(kotlin.Int,%20kotlin.String))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `trackId:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Selects a given track.                                                                                                                                                                                                                                                                                                                                                                      |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [onSetCaptionEnabled](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetCaptionEnabled(kotlin.Boolean))`(`enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Enables or disables the caption.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onSetInteractiveAppNotificationEnabled](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetInteractiveAppNotificationEnabled(kotlin.Boolean))`(`enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Enables or disables interactive app notification.                                                                                                                                                                                                                                                                                                                                                                                           |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [onSetStreamVolume](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetStreamVolume(kotlin.Float))`(`volume:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Sets the relative stream volume of the current TV input session.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onSetSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface))`(`surface:` `[Surface](https://developer.android.com/reference/kotlin/android/view/Surface.html#)?`)` Called when the application sets the surface.                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onSetTvMessageEnabled](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetTvMessageEnabled(kotlin.Int,%20kotlin.Boolean))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Called when the application enables or disables the detection of the specified message type.                                                                                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onStopPlayback](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onStopPlayback(kotlin.Int))`(`mode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the application requests playback of the Audio, Video, and CC streams to be stopped, but the metadata should continue to be filtered.                                                                                                                                                                                                                                                                                                                                                          |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onSurfaceChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSurfaceChanged(kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`format:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called after any structural changes (format or size) have been made to the surface passed in[onSetSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)).                                                    |
| open[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)           | [onTimeShiftGetCurrentPosition](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition())`()` Returns the current position for time shifting, in milliseconds since the epoch.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)           | [onTimeShiftGetStartPosition](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition())`()` Returns the start position for time shifting, in milliseconds since the epoch.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTimeShiftPause](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause())`()` Called when the application requests to pause playback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTimeShiftPlay](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))`(`recordedProgramUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!`)` Called when the application requests to play a given recorded TV program.                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTimeShiftResume](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume())`()` Called when the application requests to resume playback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTimeShiftSeekTo](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))`(`timeMs:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Called when the application requests to seek to a specified time position.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTimeShiftSetMode](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetMode(kotlin.Int))`(`mode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the application sets time shift mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTimeShiftSetPlaybackParams](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))`(`params:` `[PlaybackParams](https://developer.android.com/reference/kotlin/android/media/PlaybackParams.html#)!`)` Called when the application sets playback parameters containing the speed and audio mode.                                                                                                                                                                                                                                                                                                                                        |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onTouchEvent](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTouchEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!`)` Implement this method to handle touch screen motion events on the current input session.                                                                                                                                                                                                                                                                                                                                                                                     |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onTrackballEvent](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTrackballEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!`)` Implement this method to handle trackball events on the current input session.                                                                                                                                                                                                                                                                                                                                                                                       |
| abstract[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onTune](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTune(android.net.Uri))`(`channelUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!`)` Tunes to a given channel.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)     | [onTune](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTune(android.net.Uri,%20android.os.Bundle))`(`channelUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!`, `params:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Tunes to a given channel.                                                                                                                                                                                                                                                                                                                                                                 |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTvAdSessionData](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTvAdSessionData(kotlin.String,%20android.os.Bundle))`(`type:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `data:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Called when data from the linked[android.media.tv.ad.TvAdService](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService)is received.                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onTvMessage](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTvMessage(kotlin.Int,%20android.os.Bundle))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `data:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Called when a TV message is received                                                                                                                                                                                                                                                                                                                                                            |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [onUnblockContent](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onUnblockContent(android.media.tv.TvContentRating))`(`unblockedRating:` `[TvContentRating](https://developer.android.com/reference/kotlin/android/media/tv/TvContentRating)!`)` Requests to unblock the content according to the given rating.                                                                                                                                                                                                                                                                                                                                                                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [sendTvInputSessionData](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#sendTvInputSessionData(kotlin.String,%20android.os.Bundle))`(`type:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `data:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Sends data related to this session to corresponding linked[android.media.tv.ad.TvAdService](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService)object via TvAdView.                                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)           | [setOverlayViewEnabled](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#setOverlayViewEnabled(kotlin.Boolean))`(`enable:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Enables or disables the overlay view.                                                                                                                                                                                                                                                                                                                                                                                                                                          |

## Public constructors

### Session

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Session(context: Context!)
```

Creates a new Session.

|                                                             Parameters                                                             ||
|-----------|-------------------------------------------------------------------------------------------------------------------------|
| `context` | [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!:The context of the application |

## Public methods

### layoutSurface

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun layoutSurface(
    left: Int, 
    top: Int, 
    right: Int, 
    bottom: Int
): Unit
```

Assigns a size and position to the surface passed in[onSetSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)). The position is relative to the overlay view that sits on top of this surface.

|                                                                  Parameters                                                                   ||
|----------|-------------------------------------------------------------------------------------------------------------------------------------|
| `left`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Left position in pixels, relative to the overlay view.   |
| `top`    | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Top position in pixels, relative to the overlay view.    |
| `right`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Right position in pixels, relative to the overlay view.  |
| `bottom` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Bottom position in pixels, relative to the overlay view. |

**See Also**

- [#onOverlayViewSizeChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onOverlayViewSizeChanged(kotlin.Int,%20kotlin.Int))  

### notifyAdBufferConsumed

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyAdBufferConsumed(buffer: AdBuffer): Unit
```

Notifies the advertisement buffer is consumed.

|                                                                                                              Parameters                                                                                                              ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `buffer` | [AdBuffer](https://developer.android.com/reference/kotlin/android/media/tv/AdBuffer):the[AdBuffer](https://developer.android.com/reference/kotlin/android/media/tv/AdBuffer)that was consumed. This value cannot be`null`. |

### notifyAdResponse

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyAdResponse(response: AdResponse): Unit
```

Notifies response for advertisement.

|                                                                        Parameters                                                                        ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `response` | [AdResponse](https://developer.android.com/reference/kotlin/android/media/tv/AdResponse):advertisement response. This value cannot be`null`. |

**See Also**

- [android.media.tv.interactive.TvInteractiveAppService.Session#requestAd(AdRequest)](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppService.Session#requestAd(android.media.tv.AdRequest))  

### notifyAitInfoUpdated

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyAitInfoUpdated(aitInfo: AitInfo): Unit
```

Informs the app that the AIT (Application Information Table) is updated.

This method should also be called when[onSetInteractiveAppNotificationEnabled(boolean)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetInteractiveAppNotificationEnabled(kotlin.Boolean))is called to send the first AIT info.

|                                                        Parameters                                                         ||
|-----------|----------------------------------------------------------------------------------------------------------------|
| `aitInfo` | [AitInfo](https://developer.android.com/reference/kotlin/android/media/tv/AitInfo):This value cannot be`null`. |

**See Also**

- [#onSetInteractiveAppNotificationEnabled(boolean)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetInteractiveAppNotificationEnabled(kotlin.Boolean))  

### notifyAudioPresentationChanged

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyAudioPresentationChanged(audioPresentations: MutableList<AudioPresentation!>): Unit
```

Sends an updated list of all audio presentations available from a Next Generation Audio service. This is used by the framework to maintain the audio presentation information for a given track of[TvTrackInfo.TYPE_AUDIO](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_AUDIO:kotlin.Int), which in turn is used by[TvView.getAudioPresentations](https://developer.android.com/reference/kotlin/android/media/tv/TvView#getAudioPresentations())for the application to retrieve metadata for the current audio track. The TV input service must call this method as soon as the audio track presentation information becomes available or is updated. Note that in a case where a part of the information for the current track is updated, it is not necessary to create a new[TvTrackInfo](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo)object with a different track ID.

|                                                                                                                                                                     Parameters                                                                                                                                                                     ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `audioPresentations` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[AudioPresentation](https://developer.android.com/reference/kotlin/android/media/AudioPresentation.html#)!\>:A list of audio presentation information pertaining to the selected track. This value cannot be`null`. |

### notifyAudioPresentationSelected

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyAudioPresentationSelected(
    presentationId: Int, 
    programId: Int
): Unit
```

Sends the presentation and program IDs of the selected audio presentation. This is used to inform the application that a specific audio presentation is selected. The TV input service must call this method as soon as an audio presentation is selected either by default or in response to a call to[onSelectTrack](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSelectTrack(kotlin.Int,%20kotlin.String)). The selected audio presentation ID for a currently selected audio track is maintained in the framework until the next call to this method even after the entire audio presentation list for the track is updated (but is reset when the session is tuned to a new channel), so care must be taken not to result in an obsolete track audio presentation ID.

|                                                                          Parameters                                                                           ||
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `presentationId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The ID of the selected audio presentation for the current track. |
| `programId`      | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The ID of the program providing the selected audio presentation. |

**See Also**

- [#onSelectAudioPresentation](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSelectAudioPresentation(kotlin.Int,%20kotlin.Int))  

### notifyAvailableSpeeds

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyAvailableSpeeds(speeds: FloatArray): Unit
```

Informs the app available speeds for time-shifting.

This should be called when time-shifting is enabled.

|                                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                                           ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `speeds` | [FloatArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float-array/index.html):An ordered array of playback speeds, expressed as values relative to the normal playback speed (1.0), at which the current content can be played as a time-shifted broadcast. This is an empty array if the supported playback speeds are unknown or the video/broadcast is not in time shift mode. If currently in time shift mode, this array will normally include at least the values 1.0 (normal speed) and 0.0 (paused). This value cannot be`null`. |

**See Also**

- [android.media.PlaybackParams#getSpeed()](https://developer.android.com/reference/kotlin/android/media/PlaybackParams.html#getSpeed())  

### notifyBroadcastInfoResponse

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyBroadcastInfoResponse(response: BroadcastInfoResponse): Unit
```

Notifies response for broadcast info.

|                                                                                   Parameters                                                                                    ||
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `response` | [BroadcastInfoResponse](https://developer.android.com/reference/kotlin/android/media/tv/BroadcastInfoResponse):broadcast info response. This value cannot be`null`. |

### notifyChannelRetuned

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyChannelRetuned(channelUri: Uri!): Unit
```

Informs the application that the current channel is re-tuned for some reason and the session now displays the content from a new channel. This is used to handle special cases such as when the current channel becomes unavailable, it is necessary to send the user to a certain channel or the user changes channel in some other way (e.g. by using a dedicated remote).

|                                                       Parameters                                                       ||
|--------------|----------------------------------------------------------------------------------------------------------|
| `channelUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!:The URI of the new channel. |

### notifyContentAllowed

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyContentAllowed(): Unit
```

Informs the application that the user is allowed to watch the current program content.

Each TV input service is required to query the system whether the user is allowed to watch the current program before showing it to the user if the parental controls is enabled (i.e.[TvInputManager.isParentalControlsEnabled()](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#isParentalControlsEnabled())returns`true`). Whether the TV input service should block the content or not is determined by invoking[TvInputManager.isRatingBlocked(TvContentRating)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#isRatingBlocked(android.media.tv.TvContentRating))with the content rating for the current program. Then the[TvInputManager](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager)makes a judgment based on the user blocked ratings stored in the secure settings and returns the result. If the rating in question turns out to be allowed by the user, the TV input service must call this method to notify the application that is permitted to show the content.

Each TV input service also needs to continuously listen to any changes made to the parental controls settings by registering a broadcast receiver to receive[TvInputManager.ACTION_BLOCKED_RATINGS_CHANGED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#ACTION_BLOCKED_RATINGS_CHANGED:kotlin.String)and[TvInputManager.ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED:kotlin.String)and immediately reevaluate the current program with the new parental controls settings.  
**See Also**

- [#notifyContentBlocked](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyContentBlocked(android.media.tv.TvContentRating))
- [android.media.tv.TvInputManager](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager)  

### notifyContentBlocked

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyContentBlocked(rating: TvContentRating): Unit
```

Informs the application that the current program content is blocked by parent controls.

Each TV input service is required to query the system whether the user is allowed to watch the current program before showing it to the user if the parental controls is enabled (i.e.[TvInputManager.isParentalControlsEnabled()](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#isParentalControlsEnabled())returns`true`). Whether the TV input service should block the content or not is determined by invoking[TvInputManager.isRatingBlocked(TvContentRating)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#isRatingBlocked(android.media.tv.TvContentRating))with the content rating for the current program or[TvContentRating.UNRATED](https://developer.android.com/reference/kotlin/android/media/tv/TvContentRating#UNRATED:android.media.tv.TvContentRating)in case the rating information is missing. Then the[TvInputManager](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager)makes a judgment based on the user blocked ratings stored in the secure settings and returns the result. If the rating in question turns out to be blocked, the TV input service must immediately block the content and call this method with the content rating of the current program to prompt the PIN verification screen.

Each TV input service also needs to continuously listen to any changes made to the parental controls settings by registering a broadcast receiver to receive[TvInputManager.ACTION_BLOCKED_RATINGS_CHANGED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#ACTION_BLOCKED_RATINGS_CHANGED:kotlin.String)and[TvInputManager.ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED:kotlin.String)and immediately reevaluate the current program with the new parental controls settings.

|                                                                                                                                                                     Parameters                                                                                                                                                                     ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `rating` | [TvContentRating](https://developer.android.com/reference/kotlin/android/media/tv/TvContentRating):The content rating for the current TV program. Can be[TvContentRating.UNRATED](https://developer.android.com/reference/kotlin/android/media/tv/TvContentRating#UNRATED:android.media.tv.TvContentRating). This value cannot be`null`. |

**See Also**

- [#notifyContentAllowed](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyContentAllowed())
- [android.media.tv.TvInputManager](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager)  

### notifyCueingMessageAvailability

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyCueingMessageAvailability(available: Boolean): Unit
```

Informs the application that cueing message is available or unavailable.

The cueing message is used for digital program insertion, based on the standard ANSI/SCTE 35 2019r1.

|                                                                               Parameters                                                                               ||
|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `available` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`if cueing message is available;`false`if it becomes unavailable. |

### notifySignalStrength

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifySignalStrength(strength: Int): Unit
```

Notifies signal strength.

|                                                                                                                                                                                                                                                                                                         Parameters                                                                                                                                                                                                                                                                                                         ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `strength` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.media.tv.TvInputManager#SIGNAL_STRENGTH_LOST](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SIGNAL_STRENGTH_LOST:kotlin.Int),[android.media.tv.TvInputManager#SIGNAL_STRENGTH_WEAK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SIGNAL_STRENGTH_WEAK:kotlin.Int), or[android.media.tv.TvInputManager#SIGNAL_STRENGTH_STRONG](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SIGNAL_STRENGTH_STRONG:kotlin.Int) |

### notifyTimeShiftMode

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyTimeShiftMode(mode: Int): Unit
```

Informs the app that the time shift mode is set or updated.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The current time shift mode. The value is one of the following:[TvInputManager.TIME_SHIFT_MODE_OFF](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF:kotlin.Int),[TvInputManager.TIME_SHIFT_MODE_LOCAL](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL:kotlin.Int),[TvInputManager.TIME_SHIFT_MODE_NETWORK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK:kotlin.Int),[TvInputManager.TIME_SHIFT_MODE_AUTO](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO:kotlin.Int). Value is[android.media.tv.TvInputManager#TIME_SHIFT_MODE_OFF](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF:kotlin.Int),[android.media.tv.TvInputManager#TIME_SHIFT_MODE_LOCAL](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL:kotlin.Int),[android.media.tv.TvInputManager#TIME_SHIFT_MODE_NETWORK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK:kotlin.Int), or[android.media.tv.TvInputManager#TIME_SHIFT_MODE_AUTO](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO:kotlin.Int) |

### notifyTimeShiftStatusChanged

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyTimeShiftStatusChanged(status: Int): Unit
```

Informs the application that the time shift status is changed.

Prior to calling this method, the application assumes the status[TvInputManager.TIME_SHIFT_STATUS_UNKNOWN](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNKNOWN:kotlin.Int). Right after the session is created, it is important to invoke the method with the status[TvInputManager.TIME_SHIFT_STATUS_AVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE:kotlin.Int)if the implementation does support time shifting, or[TvInputManager.TIME_SHIFT_STATUS_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED:kotlin.Int)otherwise. Failure to notifying the current status change immediately might result in an undesirable behavior in the application such as hiding the play controls.

If the status[TvInputManager.TIME_SHIFT_STATUS_AVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE:kotlin.Int)is reported, the application assumes it can pause/resume playback, seek to a specified time position and set playback rate and audio mode. The implementation should override[onTimeShiftPause](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()),[onTimeShiftResume](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()),[onTimeShiftSeekTo](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long)),[onTimeShiftGetStartPosition](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()),[onTimeShiftGetCurrentPosition](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition())and[onTimeShiftSetPlaybackParams](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)).

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `status` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The current time shift status. Should be one of the followings. - [TvInputManager.TIME_SHIFT_STATUS_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED:kotlin.Int) - [TvInputManager.TIME_SHIFT_STATUS_UNAVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNAVAILABLE:kotlin.Int) - [TvInputManager.TIME_SHIFT_STATUS_AVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE:kotlin.Int) Value is[android.media.tv.TvInputManager#TIME_SHIFT_STATUS_UNKNOWN](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNKNOWN:kotlin.Int),[android.media.tv.TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED:kotlin.Int),[android.media.tv.TvInputManager#TIME_SHIFT_STATUS_UNAVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNAVAILABLE:kotlin.Int), or[android.media.tv.TvInputManager#TIME_SHIFT_STATUS_AVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE:kotlin.Int) |

### notifyTrackSelected

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyTrackSelected(
    type: Int, 
    trackId: String!
): Unit
```

Sends the type and ID of a selected track. This is used to inform the application that a specific track is selected. The TV input service must call this method as soon as a track is selected either by default or in response to a call to[onSelectTrack](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSelectTrack(kotlin.Int,%20kotlin.String)). The selected track ID for a given type is maintained in the framework until the next call to this method even after the entire track list is updated (but is reset when the session is tuned to a new channel), so care must be taken not to result in an obsolete track ID.

|                                                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type`    | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The type of the selected track. The type can be[TvTrackInfo.TYPE_AUDIO](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_AUDIO:kotlin.Int),[TvTrackInfo.TYPE_VIDEO](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_VIDEO:kotlin.Int)or[TvTrackInfo.TYPE_SUBTITLE](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_SUBTITLE:kotlin.Int). |
| `trackId` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The ID of the selected track.                                                                                                                                                                                                                                                                                                                                                                                                       |

**See Also**

- [#onSelectTrack](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSelectTrack(kotlin.Int,%20kotlin.String))  

### notifyTracksChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyTracksChanged(tracks: MutableList<TvTrackInfo!>!): Unit
```

Sends the list of all audio/video/subtitle tracks. The is used by the framework to maintain the track information for a given session, which in turn is used by[TvView.getTracks](https://developer.android.com/reference/kotlin/android/media/tv/TvView#getTracks(kotlin.Int))for the application to retrieve metadata for a given track type. The TV input service must call this method as soon as the track information becomes available or is updated. Note that in a case where a part of the information for a certain track is updated, it is not necessary to create a new[TvTrackInfo](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo)object with a different track ID.

|                                                                                                                         Parameters                                                                                                                         ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `tracks` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[TvTrackInfo](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo)!\>!:A list which includes track information. |

### notifyTuned

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyTuned(channelUri: Uri): Unit
```

Informs the application that this session has been tuned to the given channel.

|                                                                     Parameters                                                                      ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `channelUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#):The URI of the tuned channel. This value cannot be`null`. |

### notifyTvMessage

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyTvMessage(
    type: Int, 
    data: Bundle
): Unit
```

Sends the raw data from the received TV message as well as the type of message received.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The of message that was sent, such as[TvInputManager.TV_MESSAGE_TYPE_WATERMARK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK:kotlin.Int)Value is[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_WATERMARK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK:kotlin.Int),[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION:kotlin.Int), or[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_OTHER](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_OTHER:kotlin.Int)                                                                                                                                                                                            |
| `data` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):The raw data of the message. The bundle keys are:[TvInputManager.TV_MESSAGE_KEY_STREAM_ID](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_STREAM_ID:kotlin.String),[TvInputManager.TV_MESSAGE_KEY_GROUP_ID](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_GROUP_ID:kotlin.String),[TvInputManager.TV_MESSAGE_KEY_SUBTYPE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE:kotlin.String),[TvInputManager.TV_MESSAGE_KEY_RAW_DATA](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_RAW_DATA:kotlin.String). See[TvInputManager.TV_MESSAGE_KEY_SUBTYPE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE:kotlin.String)for more information on how to parse this data. This value cannot be`null`. |

### notifyVideoAvailable

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyVideoAvailable(): Unit
```

Informs the application that the video is now available for watching. Video is blocked until this method is called.

The TV input service must call this method as soon as the content rendered onto its surface is ready for viewing. This method must be called each time #onTune is called.  
**See Also**

- [#notifyVideoUnavailable](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoUnavailable(kotlin.Int))  

### notifyVideoFreezeUpdated

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyVideoFreezeUpdated(isFrozen: Boolean): Unit
```

Informs the application that the video freeze state has been updated.

When`true`, the video is frozen on the last frame but audio playback remains active.

|                                                            Parameters                                                             ||
|------------|-----------------------------------------------------------------------------------------------------------------------|
| `isFrozen` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):Whether or not the video is frozen |

### notifyVideoUnavailable

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyVideoUnavailable(reason: Int): Unit
```

Informs the application that the video became unavailable for some reason. This is primarily used to signal the application to block the screen not to show any intermittent video artifacts.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `reason` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The reason why the video became unavailable: - [TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN:kotlin.Int) - [TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING:kotlin.Int) - [TvInputManager.VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL:kotlin.Int) - [TvInputManager.VIDEO_UNAVAILABLE_REASON_BUFFERING](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING:kotlin.Int) - [TvInputManager.VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY:kotlin.Int) Value is[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_NOT_CONNECTED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_NOT_CONNECTED:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_INSUFFICIENT_RESOURCE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_INSUFFICIENT_RESOURCE:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_INSUFFICIENT_OUTPUT_PROTECTION](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_INSUFFICIENT_OUTPUT_PROTECTION:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_PVR_RECORDING_NOT_ALLOWED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_PVR_RECORDING_NOT_ALLOWED:kotlin.Int), android.media.tv.TvInputManager.VIDEO_UNAVAILABLE_REASON_CAS_NO_LICENSE,[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_LICENSE_EXPIRED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_LICENSE_EXPIRED:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_ACTIVATION](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_ACTIVATION:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_PAIRING](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_PAIRING:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NO_CARD](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NO_CARD:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_MUTE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_MUTE:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_INVALID](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_INVALID:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_BLACKOUT](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_BLACKOUT:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_REBOOTING](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_REBOOTING:kotlin.Int),[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_UNKNOWN](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_UNKNOWN:kotlin.Int), or[android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_STOPPED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_STOPPED:kotlin.Int) |

**See Also**

- [#notifyVideoAvailable](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoAvailable())  

### onAdBufferReady

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onAdBufferReady(buffer: AdBuffer): Unit
```

Called when an advertisement buffer is ready for playback.

|                                                                                                                    Parameters                                                                                                                     ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `buffer` | [AdBuffer](https://developer.android.com/reference/kotlin/android/media/tv/AdBuffer):The[AdBuffer](https://developer.android.com/reference/kotlin/android/media/tv/AdBuffer)that became ready for playback. This value cannot be`null`. |

### onAppPrivateCommand

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onAppPrivateCommand(
    action: String, 
    data: Bundle!
): Unit
```

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

|                                                                                                                                               Parameters                                                                                                                                               ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `action` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):Name of the command to be performed. 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](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!:Any data to include with the command.                                                                                                                                                                      |

### onCreateOverlayView

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onCreateOverlayView(): View!
```

Called when the application requests to create an overlay view. Each session implementation can override this method and return its own view.

|                                                         Return                                                         ||
|---------------------------------------------------------------------------------|---------------------------------------|
| [View](https://developer.android.com/reference/kotlin/android/view/View.html#)! | a view attached to the overlay window |

### onGenericMotionEvent

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onGenericMotionEvent(event: MotionEvent!): Boolean
```

Implement this method to handle generic motion events on the current input session.

|                                                               Parameters                                                                ||
|---------|--------------------------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!:The motion event being received. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

**See Also**

- [android.view.View#onGenericMotionEvent](https://developer.android.com/reference/kotlin/android/view/View.html#onGenericMotionEvent(android.view.MotionEvent))  

### onKeyDown

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onKeyDown(
    keyCode: Int, 
    event: KeyEvent!
): Boolean
```

Default implementation of[KeyEvent.Callback.onKeyDown()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyDown(kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).

Override this to intercept key down events before they are processed by the application. If you return true, the application will not process the event itself. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

|                                                            Parameters                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The value in event.getKeyCode().           |
| `event`   | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!:Description of the key event. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

### onKeyLongPress

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onKeyLongPress(
    keyCode: Int, 
    event: KeyEvent!
): Boolean
```

Default implementation of[KeyEvent.Callback.onKeyLongPress()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyLongPress(kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).

Override this to intercept key long press events before they are processed by the application. If you return true, the application will not process the event itself. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

|                                                            Parameters                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The value in event.getKeyCode().           |
| `event`   | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!:Description of the key event. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

### onKeyMultiple

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onKeyMultiple(
    keyCode: Int, 
    count: Int, 
    event: KeyEvent!
): Boolean
```

Default implementation of[KeyEvent.Callback.onKeyMultiple()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyMultiple(kotlin.Int,%20kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).

Override this to intercept special key multiple events before they are processed by the application. If you return true, the application will not itself process the event. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

|                                                            Parameters                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The value in event.getKeyCode().           |
| `count`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The number of times the action was made.   |
| `event`   | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!:Description of the key event. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

### onKeyUp

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onKeyUp(
    keyCode: Int, 
    event: KeyEvent!
): Boolean
```

Default implementation of[KeyEvent.Callback.onKeyUp()](https://developer.android.com/reference/kotlin/android/view/KeyEvent.Callback.html#onKeyUp(kotlin.Int,%20android.view.KeyEvent)): always returns false (doesn't handle the event).

Override this to intercept key up events before they are processed by the application. If you return true, the application will not itself process the event. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

|                                                            Parameters                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `keyCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The value in event.getKeyCode().           |
| `event`   | [KeyEvent](https://developer.android.com/reference/kotlin/android/view/KeyEvent.html#)!:Description of the key event. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

### onOverlayViewSizeChanged

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onOverlayViewSizeChanged(
    width: Int, 
    height: Int
): Unit
```

Called when the size of the overlay view is changed by the application.

This is always called at least once when the session is created regardless of whether the overlay view is enabled or not. The overlay view size is the same as the containing[TvView](https://developer.android.com/reference/kotlin/android/media/tv/TvView). Note that the size of the underlying surface can be different if the surface was changed by calling[layoutSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#layoutSurface(kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)).

|                                                      Parameters                                                      ||
|----------|------------------------------------------------------------------------------------------------------------|
| `width`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The width of the overlay view.  |
| `height` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The height of the overlay view. |

### onRelease

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onRelease(): Unit
```

Called when the session is released.  

### onRemoveBroadcastInfo

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onRemoveBroadcastInfo(requestId: Int): Unit
```

Called when broadcast info is removed.  

### onRequestAd

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onRequestAd(request: AdRequest): Unit
```

Called when advertisement request is received.

|                                                                          Parameters                                                                          ||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `request` | [AdRequest](https://developer.android.com/reference/kotlin/android/media/tv/AdRequest):advertisement request received This value cannot be`null`. |

### onRequestBroadcastInfo

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onRequestBroadcastInfo(request: BroadcastInfoRequest): Unit
```

Called when broadcast info is requested.

|                                                                                 Parameters                                                                                 ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `request` | [BroadcastInfoRequest](https://developer.android.com/reference/kotlin/android/media/tv/BroadcastInfoRequest):broadcast info request This value cannot be`null`. |

### onResumePlayback

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onResumePlayback(): Unit
```

Resumes playback of the Audio, Video, and CC streams.

Note that this is different form #timeShiftResume() as this is intended to be used after stopping playback. This is used to resume playback from the current position in the live broadcast.  

### onSelectAudioPresentation

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSelectAudioPresentation(
    presentationId: Int, 
    programId: Int
): Boolean
```

Selects an audio presentation.

On successfully selecting the audio presentation,[notifyAudioPresentationSelected](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAudioPresentationSelected(kotlin.Int,%20kotlin.Int))is invoked to provide updated information about the selected audio presentation to applications.

|                                                                          Parameters                                                                           ||
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `presentationId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The ID of the audio presentation to select.                      |
| `programId`      | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The ID of the program providing the selected audio presentation. |

|                                                                             Return                                                                             ||
|------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the audio presentation selection was successful,`false`otherwise. |

**See Also**

- [#notifyAudioPresentationSelected](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAudioPresentationSelected(kotlin.Int,%20kotlin.Int))  

### onSelectTrack

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSelectTrack(
    type: Int, 
    trackId: String?
): Boolean
```

Selects a given track.

If this is done successfully, the implementation should call[notifyTrackSelected](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTrackSelected(kotlin.Int,%20kotlin.String))to help applications maintain the up-to-date list of the selected tracks.

|                                                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                                                             ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `trackId` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?:The ID of the track to select.`null`means to unselect the current track for a given type.                                                                                                                                                                                                                                                                                                                                            |
| `type`    | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The type of the track to select. The type can be[TvTrackInfo.TYPE_AUDIO](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_AUDIO:kotlin.Int),[TvTrackInfo.TYPE_VIDEO](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_VIDEO:kotlin.Int)or[TvTrackInfo.TYPE_SUBTITLE](https://developer.android.com/reference/kotlin/android/media/tv/TvTrackInfo#TYPE_SUBTITLE:kotlin.Int). |

|                                                                      Return                                                                       ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the track selection was successful,`false`otherwise. |

**See Also**

- [#notifyTrackSelected](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyTrackSelected(kotlin.Int,%20kotlin.String))  

### onSetCaptionEnabled

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onSetCaptionEnabled(enabled: Boolean): Unit
```

Enables or disables the caption.

The locale for the user's preferred captioning language can be obtained by calling[CaptioningManager.getLocale()](https://developer.android.com/reference/kotlin/android/view/accessibility/CaptioningManager.html#getLocale()).

|                                                            Parameters                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`to enable,`false`to disable. |

**See Also**

- [android.view.accessibility.CaptioningManager](https://developer.android.com/reference/kotlin/android/view/accessibility/CaptioningManager.html#)  

### onSetInteractiveAppNotificationEnabled

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSetInteractiveAppNotificationEnabled(enabled: Boolean): Unit
```

Enables or disables interactive app notification.

This method enables or disables the event detection from the corresponding TV input. When it's enabled, the TV input service detects events related to interactive app, such as AIT (Application Information Table) and sends to TvView or the linked TV interactive app service.

|                                                            Parameters                                                            ||
|-----------|-----------------------------------------------------------------------------------------------------------------------|
| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`to enable,`false`to disable. |

**See Also**

- [android.media.tv.TvView#setInteractiveAppNotificationEnabled(boolean)](https://developer.android.com/reference/kotlin/android/media/tv/TvView#setInteractiveAppNotificationEnabled(kotlin.Boolean))
- [android.media.tv.TvInputService.Session#notifyAitInfoUpdated(android.media.tv.AitInfo)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyAitInfoUpdated(android.media.tv.AitInfo))  

### onSetStreamVolume

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onSetStreamVolume(volume: Float): Unit
```

Sets the relative stream volume of the current TV input session.

The implementation should honor this request in order to handle audio focus changes or mute the current session when multiple sessions, possibly from different inputs are active. If the method has not yet been called, the implementation should assume the default value of`1.0f`.

|                                                                               Parameters                                                                                ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `volume` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):A volume value between`0.0f`to`1.0f`. Value is between 0.0f and 1.0f inclusive |

### onSetSurface

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onSetSurface(surface: Surface?): Boolean
```

Called when the application sets the surface.

The TV input service should render video onto the given surface. When called with`null`, the input service should immediately free any references to the currently set surface and stop using it.

|                                                                         Parameters                                                                         ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `surface` | [Surface](https://developer.android.com/reference/kotlin/android/view/Surface.html#)?:The surface to be used for video rendering. Can be`null`. |

|                                                                     Return                                                                      ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the surface was set successfully,`false`otherwise. |

### onSetTvMessageEnabled

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSetTvMessageEnabled(
    type: Int, 
    enabled: Boolean
): Unit
```

Called when the application enables or disables the detection of the specified message type.

|                                                                                                                                                                                                                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type`    | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The type of message received, such as[TvInputManager.TV_MESSAGE_TYPE_WATERMARK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK:kotlin.Int)Value is[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_WATERMARK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK:kotlin.Int),[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION:kotlin.Int), or[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_OTHER](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_OTHER:kotlin.Int) |
| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`if TV message detection is enabled,`false`otherwise.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### onStopPlayback

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onStopPlayback(mode: Int): Unit
```

Called when the application requests playback of the Audio, Video, and CC streams to be stopped, but the metadata should continue to be filtered.

The metadata that will continue to be filtered includes the PSI (Program specific information) and SI (Service Information), part of ISO/IEC 13818-1.

Note that this is different form #timeShiftPause() as should release the stream, making it impossible to resume from this position again.

|                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                   ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.media.tv.interactive.TvInteractiveAppService#COMMAND_PARAMETER_VALUE_STOP_MODE_BLANK](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppService#COMMAND_PARAMETER_VALUE_STOP_MODE_BLANK:kotlin.Int), or[android.media.tv.interactive.TvInteractiveAppService#COMMAND_PARAMETER_VALUE_STOP_MODE_FREEZE](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppService#COMMAND_PARAMETER_VALUE_STOP_MODE_FREEZE:kotlin.Int) |

### onSurfaceChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSurfaceChanged(
    format: Int, 
    width: Int, 
    height: Int
): Unit
```

Called after any structural changes (format or size) have been made to the surface passed in[onSetSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)). This method is always called at least once, after[onSetSurface](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface))is called with non-null surface.

|                                                        Parameters                                                        ||
|----------|----------------------------------------------------------------------------------------------------------------|
| `format` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The new PixelFormat of the surface. |
| `width`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The new width of the surface.       |
| `height` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The new height of the surface.      |

### onTimeShiftGetCurrentPosition

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftGetCurrentPosition(): Long
```

Returns the current position for time shifting, in milliseconds since the epoch. Returns[TvInputManager.TIME_SHIFT_INVALID_TIME](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_INVALID_TIME:kotlin.Long)if the position is unknown at the moment.

The current position for time shifting is the same as the current position of playback. It should be equal to or greater than the start position reported by[onTimeShiftGetStartPosition()](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()). When playback is completed, the current position should stay where the playback ends, in other words, the returned value of this mehtod should be equal to the start position plus the duration of the program.  
**See Also**

- [#onTimeShiftPlay(Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()>
- [#onTimeShiftSeekTo(long)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))
- [#onTimeShiftSetPlaybackParams(PlaybackParams)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()>  

### onTimeShiftGetStartPosition

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftGetStartPosition(): Long
```

Returns the start position for time shifting, in milliseconds since the epoch. Returns[TvInputManager.TIME_SHIFT_INVALID_TIME](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_INVALID_TIME:kotlin.Long)if the position is unknown at the moment.

The start position for time shifting indicates the earliest possible time the user can seek to. Initially this is equivalent to the time when the implementation starts recording. Later it may be adjusted because there is insufficient space or the duration of recording is limited by the implementation. The application does not allow the user to seek to a position earlier than the start position.

For playback of a recorded program initiated by[onTimeShiftPlay(android.net.Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)), the start position should be 0 and does not change.  
**See Also**

- [#onTimeShiftPlay(Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()>
- [#onTimeShiftSeekTo(long)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))
- [#onTimeShiftSetPlaybackParams(PlaybackParams)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()>  

### onTimeShiftPause

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftPause(): Unit
```

Called when the application requests to pause playback.  
**See Also**

- [#onTimeShiftPlay(Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()>
- [#onTimeShiftSeekTo(long)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))
- [#onTimeShiftSetPlaybackParams(PlaybackParams)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()>  

### onTimeShiftPlay

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftPlay(recordedProgramUri: Uri!): Unit
```

Called when the application requests to play a given recorded TV program.

|                                                              Parameters                                                              ||
|----------------------|----------------------------------------------------------------------------------------------------------------|
| `recordedProgramUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!:The URI of a recorded TV program. |

**See Also**

- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()>
- [#onTimeShiftSeekTo(long)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))
- [#onTimeShiftSetPlaybackParams(PlaybackParams)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()>  

### onTimeShiftResume

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftResume(): Unit
```

Called when the application requests to resume playback.  
**See Also**

- [#onTimeShiftPlay(Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()>
- [#onTimeShiftSeekTo(long)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))
- [#onTimeShiftSetPlaybackParams(PlaybackParams)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()>  

### onTimeShiftSeekTo

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftSeekTo(timeMs: Long): Unit
```

Called when the application requests to seek to a specified time position. Normally, the position is given within range between the start and the current time, inclusively. The implementation is expected to seek to the nearest time position if the given position is not in the range.

|                                                                      Parameters                                                                       ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `timeMs` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):The time position to seek to, in milliseconds since the epoch. |

**See Also**

- [#onTimeShiftPlay(Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()>
- [#onTimeShiftSetPlaybackParams(PlaybackParams)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()>  

### onTimeShiftSetMode

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftSetMode(mode: Int): Unit
```

Called when the application sets time shift mode.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The time shift mode. The value is one of the following:[TvInputManager.TIME_SHIFT_MODE_OFF](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF:kotlin.Int),[TvInputManager.TIME_SHIFT_MODE_LOCAL](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL:kotlin.Int),[TvInputManager.TIME_SHIFT_MODE_NETWORK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK:kotlin.Int),[TvInputManager.TIME_SHIFT_MODE_AUTO](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO:kotlin.Int). Value is[android.media.tv.TvInputManager#TIME_SHIFT_MODE_OFF](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF:kotlin.Int),[android.media.tv.TvInputManager#TIME_SHIFT_MODE_LOCAL](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL:kotlin.Int),[android.media.tv.TvInputManager#TIME_SHIFT_MODE_NETWORK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK:kotlin.Int), or[android.media.tv.TvInputManager#TIME_SHIFT_MODE_AUTO](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO:kotlin.Int) |

### onTimeShiftSetPlaybackParams

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTimeShiftSetPlaybackParams(params: PlaybackParams!): Unit
```

Called when the application sets playback parameters containing the speed and audio mode.

Once the playback parameters are set, the implementation should honor the current settings until the next tune request. Pause/resume/seek request does not reset the parameters previously set.

|                                                             Parameters                                                              ||
|----------|---------------------------------------------------------------------------------------------------------------------------|
| `params` | [PlaybackParams](https://developer.android.com/reference/kotlin/android/media/PlaybackParams.html#)!:The playback params. |

**See Also**

- [#onTimeShiftPlay(Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftResume()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftPause()>
- [#onTimeShiftSeekTo(long)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(kotlin.Long))
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()>
- <https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()>  

### onTouchEvent

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTouchEvent(event: MotionEvent!): Boolean
```

Implement this method to handle touch screen motion events on the current input session.

|                                                               Parameters                                                                ||
|---------|--------------------------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!:The motion event being received. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

**See Also**

- [android.view.View#onTouchEvent](https://developer.android.com/reference/kotlin/android/view/View.html#onTouchEvent(android.view.MotionEvent))  

### onTrackballEvent

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTrackballEvent(event: MotionEvent!): Boolean
```

Implement this method to handle trackball events on the current input session.

|                                                               Parameters                                                                ||
|---------|--------------------------------------------------------------------------------------------------------------------------------|
| `event` | [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!:The motion event being received. |

|                                                                                                    Return                                                                                                     ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | If you handled the event, return`true`. If you want to allow the event to be handled by the next receiver, return`false`. |

**See Also**

- [android.view.View#onTrackballEvent](https://developer.android.com/reference/kotlin/android/view/View.html#onTrackballEvent(android.view.MotionEvent))  

### onTune

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onTune(channelUri: Uri!): Boolean
```

Tunes to a given channel.

No video will be displayed until[notifyVideoAvailable()](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoAvailable())is called. Also,[notifyVideoUnavailable(int)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyVideoUnavailable(kotlin.Int))should be called when the TV input cannot continue playing the given channel.

|                                                     Parameters                                                     ||
|--------------|------------------------------------------------------------------------------------------------------|
| `channelUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!:The URI of the channel. |

|                                                                  Return                                                                  ||
|------------------------------------------------------------------------------------|------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the tuning was successful,`false`otherwise. |

### onTune

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTune(
    channelUri: Uri!, 
    params: Bundle!
): Boolean
```

Tunes to a given channel. Override this method in order to handle domain-specific features that are only known between certain TV inputs and their clients.

The default implementation calls[onTune(android.net.Uri)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onTune(android.net.Uri)).

|                                                                                                                                    Parameters                                                                                                                                     ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `channelUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!:The URI of the channel.                                                                                                                                                                |
| `params`     | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!: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. |

|                                                                  Return                                                                  ||
|------------------------------------------------------------------------------------|------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the tuning was successful,`false`otherwise. |

### onTvAdSessionData

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTvAdSessionData(
    type: String, 
    data: Bundle
): Unit
```

Called when data from the linked[android.media.tv.ad.TvAdService](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService)is received.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the type of the data This value cannot be`null`. Value is[android.media.tv.ad.TvAdManager#SESSION_DATA_TYPE_AD_REQUEST](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_AD_REQUEST:kotlin.String),[android.media.tv.ad.TvAdManager#SESSION_DATA_TYPE_AD_BUFFER_READY](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_AD_BUFFER_READY:kotlin.String),[android.media.tv.ad.TvAdManager#SESSION_DATA_TYPE_BROADCAST_INFO_REQUEST](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_BROADCAST_INFO_REQUEST:kotlin.String), or[android.media.tv.ad.TvAdManager#SESSION_DATA_TYPE_REMOVE_BROADCAST_INFO_REQUEST](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_REMOVE_BROADCAST_INFO_REQUEST:kotlin.String) |
| `data` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):a bundle contains the data received This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

**See Also**

- [android.media.tv.ad.TvAdService.Session#sendTvAdSessionData(String, Bundle)](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService.Session#sendTvAdSessionData(kotlin.String,%20android.os.Bundle))
- [android.media.tv.ad.TvAdView#setTvView(TvView)](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdView#setTvView(android.media.tv.TvView))  

### onTvMessage

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTvMessage(
    type: Int, 
    data: Bundle
): Unit
```

Called when a TV message is received

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The type of message received, such as[TvInputManager.TV_MESSAGE_TYPE_WATERMARK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK:kotlin.Int)Value is[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_WATERMARK](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK:kotlin.Int),[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION:kotlin.Int), or[android.media.tv.TvInputManager#TV_MESSAGE_TYPE_OTHER](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_OTHER:kotlin.Int)                                                                                                                                                                                            |
| `data` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):The raw data of the message. The bundle keys are:[TvInputManager.TV_MESSAGE_KEY_STREAM_ID](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_STREAM_ID:kotlin.String),[TvInputManager.TV_MESSAGE_KEY_GROUP_ID](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_GROUP_ID:kotlin.String),[TvInputManager.TV_MESSAGE_KEY_SUBTYPE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE:kotlin.String),[TvInputManager.TV_MESSAGE_KEY_RAW_DATA](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_RAW_DATA:kotlin.String). See[TvInputManager.TV_MESSAGE_KEY_SUBTYPE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE:kotlin.String)for more information on how to parse this data. This value cannot be`null`. |

### onUnblockContent

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onUnblockContent(unblockedRating: TvContentRating!): Unit
```

Requests to unblock the content according to the given rating.

The implementation should unblock the content. TV input service has responsibility to decide when/how the unblock expires while it can keep previously unblocked ratings in order not to ask a user to unblock whenever a content rating is changed. Therefore an unblocked rating can be valid for a channel, a program, or certain amount of time depending on the implementation.

|                                                                     Parameters                                                                     ||
|-------------------|---------------------------------------------------------------------------------------------------------------------------------|
| `unblockedRating` | [TvContentRating](https://developer.android.com/reference/kotlin/android/media/tv/TvContentRating)!:An unblocked content rating |

### sendTvInputSessionData

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun sendTvInputSessionData(
    type: String, 
    data: Bundle
): Unit
```

Sends data related to this session to corresponding linked[android.media.tv.ad.TvAdService](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService)object via TvAdView.

Methods like[notifyBroadcastInfoResponse(android.media.tv.BroadcastInfoResponse)](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#notifyBroadcastInfoResponse(android.media.tv.BroadcastInfoResponse))sends the related data to linked[android.media.tv.interactive.TvInteractiveAppService](https://developer.android.com/reference/kotlin/android/media/tv/interactive/TvInteractiveAppService), but don't work for[android.media.tv.ad.TvAdService](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService). The method is used specifically for[android.media.tv.ad.TvAdService](https://developer.android.com/reference/kotlin/android/media/tv/ad/TvAdService)use cases.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):data type This value cannot be`null`. Value is[android.media.tv.TvInputManager#SESSION_DATA_TYPE_TUNED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TUNED:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_TRACK_SELECTED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TRACK_SELECTED:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_TRACKS_CHANGED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TRACKS_CHANGED:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_VIDEO_AVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_VIDEO_AVAILABLE:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_VIDEO_UNAVAILABLE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_VIDEO_UNAVAILABLE:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_BROADCAST_INFO_RESPONSE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_BROADCAST_INFO_RESPONSE:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_AD_RESPONSE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_AD_RESPONSE:kotlin.String),[android.media.tv.TvInputManager#SESSION_DATA_TYPE_AD_BUFFER_CONSUMED](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_AD_BUFFER_CONSUMED:kotlin.String), or[android.media.tv.TvInputManager#SESSION_DATA_TYPE_TV_MESSAGE](https://developer.android.com/reference/kotlin/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TV_MESSAGE:kotlin.String) |
| `data` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):the related data values This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### setOverlayViewEnabled

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setOverlayViewEnabled(enable: Boolean): Unit
```

Enables or disables the overlay view.

By default, the overlay view is disabled. Must be called explicitly after the session is created to enable the overlay view.

The TV input service can disable its overlay view when the size of the overlay view is insufficient to display the whole information, such as when used in Picture-in-picture. Override[onOverlayViewSizeChanged](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.Session#onOverlayViewSizeChanged(kotlin.Int,%20kotlin.Int))to get the size of the overlay view, which then can be used to determine whether to enable/disable the overlay view.

|                                                                         Parameters                                                                          ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `enable` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`if you want to enable the overlay view.`false`otherwise. |