### Start Local Development Server Source: https://github.com/android/tv-samples/blob/main/LeanbackShowcase/server/readme.org Use this command to start the local development server for the Android TV Showcase application. Ensure you have the Google Cloud SDK installed and configured. ```shell $YOUR_PATH_TO/google-cloud-sdk/bin/dev_appserver.py ./ ``` -------------------------------- ### Install Node Packages for Server Source: https://github.com/android/tv-samples/blob/main/ReferenceAppKotlin/firebase/README.md Navigate to the server directory and run this command to install all necessary Node.js dependencies for the backend. ```bash cd {project_folder}/firebase/server npm install ``` -------------------------------- ### Install Node Packages for Web App Source: https://github.com/android/tv-samples/blob/main/ReferenceAppKotlin/firebase/README.md Navigate to the web directory and run this command to install all necessary Node.js dependencies for the web application. ```bash cd {project_folder}/firebase/web npm install ``` -------------------------------- ### Start Jetstream App Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/baseline-profiles.md Use this command to start the Jetstream app. This is useful for manual testing or when setting up performance benchmarks. ```bash adb shell am start -n com.google.jetstream/com.google.jetstream.MainActivity ``` -------------------------------- ### Simulate Home Screen Channel Initialization Source: https://github.com/android/tv-samples/blob/main/ReferenceAppKotlin/README.md This ADB command simulates the system broadcast that triggers the creation of home screen channels when an app is installed. Use this to test channel creation manually. ```sh adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n com.android.tv.reference/.homescreenchannels.HomeScreenChannelReceiver ``` -------------------------------- ### Output Stream Information Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for retrieving and setting output stream offset and start time. ```APIDOC ## getOutputStreamOffsetUs ### Description Gets the output stream offset in microseconds. ### Method `public long getOutputStreamOffsetUs()` ## getOutputStreamStartPositionUs ### Description Gets the output stream start position in microseconds. ### Method `public long getOutputStreamStartPositionUs()` ## onOutputStreamOffsetUsChanged ### Description Callback when the output stream offset has changed. ### Method `public void onOutputStreamOffsetUsChanged(long outputStreamOffsetUs)` ### Parameters - **outputStreamOffsetUs** (long) - The new output stream offset in microseconds. ## setOutputStreamInfo ### Description Sets information about the output stream. ### Method `public void setOutputStreamInfo(MediaCodecRenderer.OutputStreamInfo outputStreamInfo)` ### Parameters - **outputStreamInfo** (MediaCodecRenderer.OutputStreamInfo) - The output stream information. ``` -------------------------------- ### ExoPlayerImpl Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt This section lists various methods available in the ExoPlayerImpl class for managing playback, media, and player state. ```APIDOC ## ExoPlayerImpl Methods This section details the public methods of the `ExoPlayerImpl` class. ### `addAnalyticsListener` Adds an analytics listener to receive playback events. - **Parameters** - `listener` (AnalyticsListener) - The listener to add. ### `addAudioOffloadListener` Adds an audio offload listener. - **Parameters** - `listener` (ExoPlayer.AudioOffloadListener) - The listener to add. ### `addListener` Adds a player listener for general playback events. - **Parameters** - `listener` (Player.Listener) - The listener to add. ### `addMediaSourceHolders` Adds media source holders to the player. - **Parameters** - `index` (int) - The index at which to add the media sources. - `mediaSources` (List) - A list of media sources to add. - **Returns** - `List` - The list of added media source holders. ### `buildUpdatedMediaMetadata` Builds updated media metadata. - **Returns** - `MediaMetadata` - The updated media metadata. ### `computePlaybackSuppressionReason` Computes the playback suppression reason. - **Parameters** - `playWhenReady` (boolean) - Whether playback is ready. - `playbackSuppressionReason` (int) - The current playback suppression reason. - **Returns** - `int` - The computed playback suppression reason. ### `createDeviceInfo` Creates device information. - **Parameters** - `streamVolumeManager` (StreamVolumeManager) - The stream volume manager. - **Returns** - `DeviceInfo` - The device information. ### `createMaskingTimeline` Creates a masking timeline. - **Returns** - `Timeline` - The masking timeline. ### `createMediaSources` Creates media sources from a list of media items. - **Parameters** - `mediaItems` (List) - A list of media items. - **Returns** - `List` - A list of created media sources. ### `createMessageInternal` Creates an internal player message. - **Parameters** - `target` (PlayerMessage.Target) - The target for the message. - **Returns** - `PlayerMessage` - The created player message. ### `evaluateMediaItemTransitionReason` Evaluates the reason for media item transition. - **Parameters** - `previousPlaybackInfo` (PlaybackInfo) - The previous playback info. - `currentPlaybackInfo` (PlaybackInfo) - The current playback info. - `isSeeking` (boolean) - Whether seeking is in progress. - `isLooping` (boolean) - Whether looping is enabled. - `isRewinding` (boolean) - Whether rewinding is in progress. - **Returns** - `Pair` - A pair containing the transition reason and media item index. ### `getApplicationLooper` Gets the application's looper. - **Returns** - `Looper` - The application looper. ### `getAvailableCommands` Gets the available player commands. - **Returns** - `Player.Commands` - The set of available commands. ### `getContentPosition` Gets the current content position in milliseconds. - **Returns** - `long` - The content position. ### `getContentPositionInternal` Gets the internal content position. - **Parameters** - `playbackInfo` (PlaybackInfo) - The current playback info. - **Returns** - `long` - The internal content position. ### `getCurrentAdGroupIndex` Gets the index of the current ad group. - **Returns** - `int` - The current ad group index. ### `getCurrentAdIndexInAdGroup` Gets the index of the current ad within the ad group. - **Returns** - `int` - The current ad index in the ad group. ### `getCurrentCues` Gets the current cues (subtitles or captions). - **Returns** - `CueGroup` - The current cue group. ### `getCurrentMediaItemIndex` Gets the index of the current media item. - **Returns** - `int` - The current media item index. ### `getCurrentPeriodIndex` Gets the index of the current period. - **Returns** - `int` - The current period index. ### `getCurrentPosition` Gets the current playback position in milliseconds. - **Returns** - `long` - The current playback position. ### `getCurrentPositionUsInternal` Gets the current playback position in microseconds. - **Parameters** - `playbackInfo` (PlaybackInfo) - The current playback info. - **Returns** - `long` - The current playback position in microseconds. ### `getCurrentTimeline` Gets the current playback timeline. - **Returns** - `Timeline` - The current timeline. ### `getCurrentTracks` Gets the current tracks (audio, video, text). - **Returns** - `Tracks` - The current tracks. ### `getCurrentWindowIndexInternal` Gets the internal current window index. - **Parameters** - `playbackInfo` (PlaybackInfo) - The current playback info. - **Returns** - `int` - The internal current window index. ### `getDuration` Gets the total duration of the media in milliseconds. - **Returns** - `long` - The media duration. ### `getPlayWhenReady` Gets the current play-when-ready state. - **Returns** - `boolean` - True if the player is set to play when ready, false otherwise. ### `getPlayWhenReadyChangeReason` Gets the reason for the play-when-ready state change. - **Parameters** - `playWhenReady` (boolean) - The current play-when-ready state. - `reason` (int) - The previous reason for the change. - **Returns** - `int` - The reason for the play-when-ready change. ### `getPlaybackState` Gets the current playback state. - **Returns** - `int` - The playback state (e.g., STATE_IDLE, STATE_READY, STATE_BUFFERING, STATE_ENDED). ### `getPlaybackSuppressionReason` Gets the reason why playback is suppressed. - **Returns** - `int` - The playback suppression reason. ### `getPlayerError` (overload 1) Gets the current player error. - **Returns** - `PlaybackException` - The player error. ### `getPlayerError` (overload 2) Gets the current player error. - **Returns** - `ExoPlaybackException` - The player error. ### `getPositionInfo` Gets position information for a given playback position. - **Parameters** - `positionMs` (long) - The playback position in milliseconds. - **Returns** - `Player.PositionInfo` - The position information. ### `getPreviousPositionInfo` Gets position information for the previous playback state. - **Parameters** - `mediaItemIndex` (int) - The index of the media item. - `playbackInfo` (PlaybackInfo) - The current playback info. - `periodIndex` (int) - The index of the period. - **Returns** - `Player.PositionInfo` - The previous position information. ### `getRepeatMode` Gets the repeat mode. - **Returns** - `int` - The repeat mode (e.g., REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL). ### `getShuffleModeEnabled` Gets whether shuffle mode is enabled. - **Returns** - `boolean` - True if shuffle mode is enabled, false otherwise. ### `getTotalBufferedDuration` Gets the total buffered duration in milliseconds. - **Returns** - `long` - The total buffered duration. ### `getVideoSize` Gets the video size. - **Returns** - `VideoSize` - The video size. ### `handlePlaybackInfo` Handles playback information updates from the internal player. - **Parameters** - `playbackInfoUpdate` (ExoPlayerImplInternal.PlaybackInfoUpdate) - The playback info update. ### `isPlayingAd` Checks if the player is currently playing an ad. - **Returns** - `boolean` - True if an ad is playing, false otherwise. ### `isSleepingForOffload` Checks if the player is sleeping for audio offload. - **Returns** - `boolean` - True if sleeping for offload, false otherwise. ### `lambda$maybeNotifySurfaceSizeChanged$27` Internal lambda for notifying surface size changes. - **Parameters** - `width` (int) - The new width. - `height` (int) - The new height. - `listener` (Player.Listener) - The listener to notify. ### `lambda$new$0` Internal lambda for listener updates. - **Parameters** - `listener` (Player.Listener) - The listener. - `commands` (FlagSet) - The set of commands. ### `lambda$new$1` Internal lambda for playback info updates. - **Parameters** - `playbackInfoUpdate` (ExoPlayerImplInternal.PlaybackInfoUpdate) - The playback info update. ### `lambda$new$2` Internal lambda for playback info updates. - **Parameters** - `playbackInfoUpdate` (ExoPlayerImplInternal.PlaybackInfoUpdate) - The playback info update. ### `lambda$setRepeatMode$3` Internal lambda for setting repeat mode. - **Parameters** - `repeatMode` (int) - The repeat mode. - `listener` (Player.Listener) - The listener to notify. ### `lambda$updateAvailableCommands$26` Internal lambda for updating available commands. - **Parameters** - `listener` (Player.Listener) - The listener to update. ``` -------------------------------- ### MediaSource.Factory Static Initialization Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Static initialization block for MediaSource.Factory. ```APIDOC ## MediaSource.Factory ### Description Factory interface for creating `MediaSource` instances. ### Static Initialization #### `()` Static initializer for the `MediaSource.Factory` interface. ``` -------------------------------- ### NavGraph API Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Provides methods for managing navigation graphs, including destinations and start destinations. ```APIDOC ## NavGraph Methods ### Description Methods for interacting with navigation graphs. ### Methods - `addDestination(destination: NavDestination)` - `addDestinations(destinations: Collection)` - `equals(other: Any?): Boolean` - `findNode(id: Int): NavDestination?` - `findNode(id: Int, saveState: Boolean): NavDestination?` - `findNode(route: String, exact: Boolean): NavDestination?` - `getNodes(): SparseArrayCompat` - `getStartDestinationId(): Int` - `getStartDestinationRoute(): String?` - `hashCode(): Int` - `iterator(): Iterator` - `matchDeepLink(request: NavDeepLinkRequest): NavDestination.DeepLinkMatch?` - `setStartDestination(route: String)` - `setStartDestinationRoute(route: String?)` ``` -------------------------------- ### Clone the Android TV Samples Repository Source: https://github.com/android/tv-samples/blob/main/ClassicsKotlin/README.md Use this command to clone the repository containing the Android TV samples. ```sh git clone https://github.com/android/tv-samples.git ``` -------------------------------- ### Array Indexing and Searching Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Utilities for getting the last index of an array and finding the index of an element. ```APIDOC ## getLastIndex ### Description Gets the index of the last element in an array. ### Method `getLastIndex` ### Parameters - `array` (Array) - The input array. ### Returns - `Int` - The index of the last element. ``` ```APIDOC ## indexOf ### Description Finds the index of the first occurrence of a specified element in an array. ### Method `indexOf` ### Parameters - `array` (Array) - The array to search within. - `element` (T) - The element to search for. ### Returns - `Int` - The index of the first occurrence of the element, or -1 if not found. ``` -------------------------------- ### Schedule TvMediaSynchronizer Worker Source: https://context7.com/android/tv-samples/llms.txt Schedule this one-time work request once on app start. Call from Application.onCreate or the first Activity. ```kotlin val syncRequest = OneTimeWorkRequestBuilder().build() WorkManager.getInstance(context).enqueue(syncRequest) ``` -------------------------------- ### MediaBrowserFragment Implementation Source: https://context7.com/android/tv-samples/llms.txt Subclass of BrowseSupportFragment for Leanback UI. Loads media collections, animates background tints using Palette, and handles navigation to playback. Requires TvMediaMetadata and TvMediaDatabase. ```kotlin class MediaBrowserFragment : BrowseSupportFragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) headersState = BrowseSupportFragment.HEADERS_DISABLED adapter = ArrayObjectAdapter(ListRowPresenter()) // Dynamic background tint when item is focused setOnItemViewSelectedListener { _, item, _, _ -> val metadata = item as? TvMediaMetadata ?: return@setOnItemViewSelectedListener lifecycleScope.launch(Dispatchers.IO) { metadata.artUri?.let { uri -> Coil.get(uri) { allowHardware(false) }.toBitmap() }?.let { bitmap -> Palette.Builder(bitmap).generate { palette -> val dominant = palette?.getDominantColor(currentTintColor) ?: currentTintColor val tint = ColorUtils.setAlphaComponent(dominant, 150 /* alpha */) updateBackgroundTint(tint) } } } } // Navigate to playback on click setOnItemViewClickedListener { _, item, _, _ -> val metadata = item as TvMediaMetadata Navigation.findNavController(requireActivity(), R.id.fragment_container) .navigate(MediaBrowserFragmentDirections.actionToNowPlaying(metadata)) } // Sync media database and populate rows lifecycleScope.launch(Dispatchers.IO) { populateAdapter(adapter as ArrayObjectAdapter) TvMediaSynchronizer.synchronize(requireContext()) } } private fun populateAdapter(adapter: ArrayObjectAdapter) { val database = TvMediaDatabase.getInstance(requireContext()) val rows = database.collections().findAll().mapIndexed { idx, collection -> val header = HeaderItem(idx.toLong(), collection.title) val rowAdapter = ArrayObjectAdapter(TvMediaMetadataPresenter()).apply { setItems(database.metadata().findByCollection(collection.id), null) } ListRow(header, rowAdapter) } adapter.setItems(rows, listRowDiffCallback) } } ``` -------------------------------- ### Watch Next Update Listener Source: https://context7.com/android/tv-samples/llms.txt An example implementation of PlaybackStateListener that updates watch next recommendations when playback is paused or ends. Requires a Context and WatchNextHelper. ```kotlin // Example listener: update Watch Next on Pause / End class WatchNextPlaybackStateListener(private val context: Context) : PlaybackStateListener { override fun onStateChange(state: VideoPlaybackState) { when (state) { is VideoPlaybackState.Pause -> WatchNextHelper.handleWatchNextForMovie( state.video, state.position.toInt(), WatchNextHelper.PLAY_STATE_PAUSED, context ) is VideoPlaybackState.End -> WatchNextHelper.handleWatchNextForMovie( state.video, 0, WatchNextHelper.PLAY_STATE_ENDED, context ) else -> { /* no-op */ } } } } ``` -------------------------------- ### MediaMetadata.Builder Population Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for populating the MediaMetadata.Builder from existing MediaMetadata or lists of metadata. ```APIDOC ## MediaMetadata.Builder Population Methods These methods allow for initializing or updating the builder with existing metadata. ### Methods - `populate(MediaMetadata)`: Populates the builder with data from an existing MediaMetadata object. - `populateFromMetadata(List)`: Populates the builder from a list of Metadata.Entry objects. ``` -------------------------------- ### Watch Progress Persistence Listener Source: https://context7.com/android/tv-samples/llms.txt An example implementation of PlaybackStateListener that saves watch progress when playback is paused and deletes it when the video ends. Requires a WatchProgressRepository. ```kotlin // Example listener: persist watch progress on Pause / End class WatchProgressPlaybackStateListener( private val watchProgressRepository: WatchProgressRepository ) : PlaybackStateListener { override fun onStateChange(state: VideoPlaybackState) { when (state) { is VideoPlaybackState.Pause -> watchProgressRepository.save(WatchProgress(state.video.id, state.position)) is VideoPlaybackState.End -> watchProgressRepository.delete(state.video.id) else -> { /* no-op */ } } } } ``` -------------------------------- ### Activity Builders Module for SearchActivity Source: https://github.com/android/tv-samples/blob/main/LeanbackShowcase/UsingDaggerWithLeanback.org Defines a Dagger module to contribute an Android injector factory for SearchActivity. This setup is crucial for activity-level dependency injection within the application. ```java public abstract class ActivityBuildersModule_ContributeToAndriodInjectorForSearchActivity { private ActivityBuildersModule_ContributeToAndriodInjectorForSearchActivity() {} // generate the binds method for us @Binds @IntoMap @ActivityKey(SearchActivity.class) abstract AndroidInjector.Factory bindAndroidInjectorFactory( SearchActivitySubcomponent.Builder builder); // factory is actually the father class of builder. We call the module as activity bulider module/ // fragment builder module is because for subcomponent it can usually be represented using builder interface // generate the subcomponent for us @Subcomponent( modules = { SearchActivityModule.class, SearchFragmentInjectorInstallmentFactoryBindingModule.class } ) @PerActivity public interface SearchActivitySubcomponent extends AndroidInjector { @Subcomponent.Builder abstract class Builder extends AndroidInjector.Builder {} } } ``` -------------------------------- ### AsynchronousMediaCodecAdapter.Factory Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Provides documentation for the public methods of the AsynchronousMediaCodecAdapter.Factory class. ```APIDOC ## AsynchronousMediaCodecAdapter.Factory ### Description Factory for creating AsynchronousMediaCodecAdapter instances. ### Methods #### createAdapter ##### Description Creates an AsynchronousMediaCodecAdapter. ##### Method PL ##### Parameters - **configuration** (androidx.media3.exoplayer.mediacodec.MediaCodecAdapter.Configuration) - Required - The configuration for the adapter. #### experimentalSetAsyncCryptoFlagEnabled ##### Description Enables or disables the asynchronous crypto flag. ##### Method PL ##### Parameters - **enabled** (Z) - Required - Whether to enable the flag. #### useSynchronousBufferQueueingWithAsyncCryptoFlag ##### Description Checks if synchronous buffer queueing should be used with the async crypto flag. ##### Method PL ##### Parameters - **format** (androidx.media3.common.Format) - Required - The media format. ``` -------------------------------- ### ExoPlayerImpl Public Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt This section details the public methods of the ExoPlayerImpl class that are directly callable by users for controlling media playback. ```APIDOC ## ExoPlayerImpl ### Public Methods #### prepare() ##### Description Initializes the player. ##### Method `prepare()` #### release() ##### Description Releases all resources associated with the player. ##### Method `release()` #### removeSurfaceCallbacks() ##### Description Removes any previously set surface callbacks. ##### Method `removeSurfaceCallbacks()` #### seekTo(positionMs: Long, seekPosition: SeekPosition, playWhenReady: Boolean, forceSeek: Boolean) ##### Description Seeks to a specified position in the media. ##### Method `seekTo(positionMs: Long, seekPosition: SeekPosition, playWhenReady: Boolean, forceSeek: Boolean)` #### sendRendererMessage(rendererIndex: Int, messageCode: Int, payload: Any) ##### Description Sends a message to a specific renderer. ##### Method `sendRendererMessage(rendererIndex: Int, messageCode: Int, payload: Any)` #### setMediaItems(mediaItems: List, resetPosition: Boolean) ##### Description Sets a list of media items to be played. ##### Method `setMediaItems(mediaItems: List, resetPosition: Boolean)` #### setMediaSources(mediaSources: List, resetPosition: Boolean) ##### Description Sets a list of media sources to be played. ##### Method `setMediaSources(mediaSources: List, resetPosition: Boolean)` #### setPlayWhenReady(playWhenReady: Boolean) ##### Description Controls whether the player should play when ready. ##### Method `setPlayWhenReady(playWhenReady: Boolean)` #### setRepeatMode(repeatMode: Int) ##### Description Sets the repeat mode for playback. ##### Method `setRepeatMode(repeatMode: Int)` #### setVideoSurfaceHolder(surfaceHolder: SurfaceHolder) ##### Description Sets the SurfaceHolder for video rendering. ##### Method `setVideoSurfaceHolder(surfaceHolder: SurfaceHolder)` #### setVideoSurfaceView(surfaceView: SurfaceView) ##### Description Sets the SurfaceView for video rendering. ##### Method `setVideoSurfaceView(surfaceView: SurfaceView)` #### updateAvailableCommands() ##### Description Updates the available playback commands based on the current player state. ##### Method `updateAvailableCommands()` #### updatePlaybackInfoForPlayWhenReadyAndSuppressionReasonStates(playWhenReady: Boolean, playbackSuppressionReason: Int) ##### Description Updates the playback info based on playWhenReady and suppression reason states. ##### Method `updatePlaybackInfoForPlayWhenReadyAndSuppressionReasonStates(playWhenReady: Boolean, playbackSuppressionReason: Int)` #### updatePriorityTaskManagerForIsLoadingChange(isLoading: Boolean) ##### Description Updates the PriorityTaskManager based on the player's loading state. ##### Method `updatePriorityTaskManagerForIsLoadingChange(isLoading: Boolean)` #### verifyApplicationThread() ##### Description Verifies that the current thread is the application thread. ##### Method `verifyApplicationThread()` ``` -------------------------------- ### ConnectInterceptor Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Intercepts connection establishment in OkHttp requests. ```APIDOC ## ConnectInterceptor ### Methods - **()**: Class initializer. - **()**: Constructor. - **intercept(Lokhttp3/Interceptor$Chain;)Lokhttp3/Response;**: Intercepts the request chain to handle connection logic. ``` -------------------------------- ### WrappingMediaSource Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for creating and managing `MediaSource` instances that wrap other `MediaSource`s. ```APIDOC ## WrappingMediaSource ### Description A `MediaSource` that wraps another `MediaSource`, allowing for modification or interception of its behavior. ### Methods - `getMediaPeriodIdForChildMediaPeriodId(Object childMediaPeriodId, MediaSource.MediaPeriodId mediaPeriodId)`: Maps a child media period ID to the corresponding media period ID of this source. - `getMediaTimeForChildMediaTime(long childTimeUs, MediaSource.MediaPeriodId mediaPeriodId)`: Converts a media time from a child source to this source's media time. - `getWindowIndexForChildWindowIndex(int childWindowIndex)`: Maps a child window index to this source's window index. - `onChildSourceInfoRefreshed(Object childSourceInfo, MediaSource mediaSource, Timeline timeline)`: Callback invoked when the child source's information is refreshed. - `prepareChildSource(MediaSource childSource)`: Prepares a child media source for playback. - `prepareSourceInternal(TransferListener transferListener)`: Internal method to prepare the source. ``` -------------------------------- ### Transition Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Documentation for the Transition class, used for managing state changes and animations within a defined scope. ```APIDOC ## Transition ### Description Manages animations and state changes over time, often used for UI transitions. ### Constructors - `Transition(state: TransitionState, initial: Any, label: String)` - `Transition(initial: Any, label: String)` ### Methods - `animateTo(targetState: Any, composer: Composer, changed: Int)`: Animates the transition to a new target state. - `getCurrentState()`: Returns the current state of the transition. - `getHasInitialValueAnimations()`: Checks if there are animations for the initial value. - `getLabel()`: Returns the label associated with the transition. - `getPlayTimeNanos()`: Gets the current playback time in nanoseconds. - `getSegment()`: Retrieves the current animation segment. - `getStartTimeNanos()`: Gets the start time of the transition in nanoseconds. - `getTargetState()`: Returns the target state of the transition. - `getUpdateChildrenNeeded()`: Indicates if child animations need updating. - `isRunning()`: Checks if the transition is currently running. - `isSeeking()`: Checks if the transition is in a seeking state. - `onChildAnimationUpdated()`: Callback for when a child animation is updated. - `onDisposed()`: Callback when the transition is disposed. - `onFrame(timeNanos: Long, fraction: Float)`: Called on each frame to update animations. - `onFrame(timeNanos: Long, isSeeking: Boolean)`: Called on each frame, with seeking state. - `onTransitionEnd()`: Callback when the transition finishes. - `onTransitionStart(startTimeNanos: Long)`: Callback when the transition begins. - `removeAnimation(animation: DeferredAnimation)`: Removes a deferred animation. - `removeAnimation(animation: TransitionAnimationState)`: Removes a transition animation state. - `removeTransition(transition: Transition)`: Removes a nested transition. - `resetAnimations()`: Resets all animations within the transition. - `setPlayTimeNanos(playTimeNanos: Long)`: Sets the playback time in nanoseconds. - `setSeeking(seeking: Boolean)`: Sets the seeking state of the transition. - `setSegment(segment: Segment)`: Sets the current animation segment. - `setStartTimeNanos(startTimeNanos: Long)`: Sets the start time of the transition in nanoseconds. - `setTargetState(targetState: Any)`: Sets the target state for the transition. - `setUpdateChildrenNeeded(update: Boolean)`: Sets whether child animations need updating. - `updateTarget(targetState: Any)`: Updates the target state of the transition. ``` -------------------------------- ### MediaSource.MediaPeriodId Constructors and Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Constructors and methods for the MediaPeriodId class. ```APIDOC ## MediaSource.MediaPeriodId ### Description Represents an identifier for a media period. ### Constructors #### `(Object manifest)` Constructor for `MediaPeriodId` with a manifest. #### `(Object manifest, int prefixAdGroupIndex, int adIndexInAdGroup, long contentPositionUs, int overrideAdDurationUs)` Constructor for `MediaPeriodId` with detailed ad and content information. #### `(Object manifest, long contentPositionUs)` Constructor for `MediaPeriodId` with a manifest and content position. #### `(Object manifest, long contentPositionUs, int adGroupIndex)` Constructor for `MediaPeriodId` with a manifest, content position, and ad group index. #### `(Object manifest, long contentPositionUs, int adGroupIndex, int adIndexInAdGroup)` Constructor for `MediaPeriodId` with a manifest, content position, ad group index, and ad index. ### Methods #### `copyWithPeriodUid(Object periodUid)` Creates a new `MediaPeriodId` with a different period UID. #### `equals(Object obj)` Checks if this `MediaPeriodId` is equal to another object. ``` -------------------------------- ### TrackSelectionParameters Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for configuring and building track selection parameters, including audio offload preferences. ```APIDOC ## TrackSelectionParameters Methods ### Description Provides methods for creating and configuring track selection parameters, including specific settings for audio offload. ### Methods - `TrackSelectionParameters(builder: TrackSelectionParameters.Builder)` ## TrackSelectionParameters.AudioOffloadPreferences Methods ### Description Methods for configuring audio offload preferences within track selection. ### Methods - `AudioOffloadPreferences(builder: TrackSelectionParameters.AudioOffloadPreferences.Builder)` - `build(): TrackSelectionParameters.AudioOffloadPreferences` ``` -------------------------------- ### Codec State and Configuration Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods related to codec state, configuration, and initialization. ```APIDOC ## getCodecBufferFlags ### Description Gets the flags for a decoder input buffer. ### Method `public int getCodecBufferFlags(DecoderInputBuffer inputBuffer)` ### Parameters - **inputBuffer** (DecoderInputBuffer) - The input buffer. ## getCodecNeedsEosPropagation ### Description Checks if the codec needs End-Of-Stream propagation. ### Method `public boolean getCodecNeedsEosPropagation()` ## getCodecOutputMediaFormat ### Description Gets the output media format of the codec. ### Method `public MediaFormat getCodecOutputMediaFormat()` ## initCodec ### Description Initializes the codec with the given codec info and crypto. ### Method `public void initCodec(MediaCodecInfo codecInfo, MediaCrypto crypto)` ### Parameters - **codecInfo** (MediaCodecInfo) - Information about the codec to initialize. - **crypto** (MediaCrypto) - The MediaCrypto object for secure decoding. ## maybeInitCodecOrBypass ### Description Initializes the codec or bypass if conditions are met. ### Method `public void maybeInitCodecOrBypass()` ## maybeInitCodecWithFallback ### Description Initializes the codec with a fallback mechanism if the initial attempt fails. ### Method `public void maybeInitCodecWithFallback(MediaCrypto crypto, boolean forceReinit)` ### Parameters - **crypto** (MediaCrypto) - The MediaCrypto object for secure decoding. - **forceReinit** (boolean) - Whether to force reinitialization. ## onReadyToInitializeCodec ### Description Callback when the renderer is ready to initialize the codec. ### Method `public void onReadyToInitializeCodec(Format format)` ### Parameters - **format** (Format) - The media format for which the codec should be initialized. ## shouldInitCodec ### Description Determines if the codec should be initialized based on the provided codec info. ### Method `public boolean shouldInitCodec(MediaCodecInfo codecInfo)` ### Parameters - **codecInfo** (MediaCodecInfo) - Information about the potential codec. ## shouldReinitCodec ### Description Determines if the codec needs to be reinitialized. ### Method `public boolean shouldReinitCodec()` ``` -------------------------------- ### launchAnimation Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Launches the animation to bring content into view. ```APIDOC ## launchAnimation ### Description Launches the animation to bring content into view. ``` -------------------------------- ### Traditional Activity Injection with Dagger Source: https://github.com/android/tv-samples/blob/main/LeanbackShowcase/UsingDaggerWithLeanback.org Illustrates the traditional method of performing dependency injection for an Activity using Dagger's sub-component pattern. Ensure the application component is accessed and the sub-component is built and injected before using injected fields. ```java public class FrombulationActivity extends Activity { @Inject Frombulator frombulator; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // DO THIS FIRST. Otherwise frombulator might be null! ((SomeApplicationBaseType) getContext().getApplicationContext()) .getApplicationComponent() .newActivityComponentBuilder() .activity(this) .build() .inject(this); // ... now you can write the exciting code } } ``` -------------------------------- ### SlotWriter.Companion Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Documentation for static methods available on the SlotWriter.Companion object. ```APIDOC ## SlotWriter.Companion Methods This section details the static methods available on the `SlotWriter.Companion` object. ### `()` Constructor for SlotWriter.Companion. ### `(DefaultConstructorMarker)` Constructor for SlotWriter.Companion with a default marker. ### `access$moveGroup(SlotWriter.Companion, SlotWriter, Int, SlotWriter, Boolean, Boolean, Boolean)` Internal access method for moving groups. ### `moveGroup(SlotWriter, Int, SlotWriter, Boolean, Boolean, Boolean)` Moves a group from one SlotWriter to another with various options. ``` -------------------------------- ### AsynchronousMediaCodecAdapter Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Provides documentation for the public methods of the AsynchronousMediaCodecAdapter class. ```APIDOC ## AsynchronousMediaCodecAdapter ### Description Provides an asynchronous adapter for MediaCodec operations. ### Methods #### dequeueInputBufferIndex ##### Description Dequeues an available input buffer index. ##### Method HPL #### dequeueOutputBufferIndex ##### Description Dequeues an available output buffer index. ##### Method HPL ##### Parameters - **bufferInfo** (android.media.MediaCodec.BufferInfo) - Required - Information about the dequeued buffer. #### flush ##### Description Flushes the codec. ##### Method PL #### getInputBuffer ##### Description Gets the input buffer associated with the given index. ##### Method HPL ##### Parameters - **index** (I) - Required - The index of the input buffer. #### getOutputBuffer ##### Description Gets the output buffer associated with the given index. ##### Method HPL ##### Parameters - **index** (I) - Required - The index of the output buffer. #### getOutputFormat ##### Description Gets the current output format of the codec. ##### Method PL #### initialize ##### Description Initializes the codec with the given parameters. ##### Method PL ##### Parameters - **format** (android.media.MediaFormat) - Required - The media format. - **surface** (android.view.Surface) - Required - The output surface. - **crypto** (android.media.MediaCrypto) - Required - The media crypto. - **flags** (I) - Required - Initialization flags. #### needsReconfiguration ##### Description Checks if the codec needs reconfiguration. ##### Method PL #### queueInputBuffer ##### Description Queues an input buffer to the codec. ##### Method HPL ##### Parameters - **index** (I) - Required - The index of the input buffer. - **offset** (I) - Required - The offset into the buffer. - **size** (I) - Required - The size of the data in the buffer. - **presentationTimeUs** (J) - Required - The presentation time in microseconds. - **flags** (I) - Required - Buffer flags. #### release ##### Description Releases the codec resources. ##### Method PL #### releaseOutputBuffer ##### Description Releases an output buffer. ##### Method HPL ##### Parameters - **index** (I) - Required - The index of the output buffer. - **render** (Z) - Required - Whether to render the buffer. #### releaseOutputBuffer ##### Description Releases an output buffer. ##### Method HPL ##### Parameters - **index** (I) - Required - The index of the output buffer. - **render** (Z) - Required - Whether to render the buffer. #### setOutputSurface ##### Description Sets the output surface for the codec. ##### Method PL ##### Parameters - **surface** (android.view.Surface) - Required - The output surface. #### setVideoScalingMode ##### Description Sets the video scaling mode for the codec. ##### Method PL ##### Parameters - **scalingMode** (I) - Required - The video scaling mode. ``` -------------------------------- ### TaskRunner.RealBackend Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Implementation of the TaskRunner backend for executing tasks. ```APIDOC ## TaskRunner.RealBackend ### Methods - **(Ljava/util/concurrent/ThreadFactory;)V**: Constructor that takes a ThreadFactory. - **coordinatorNotify(Lokhttp3/internal/concurrent/TaskRunner;)V**: Notifies the coordinator. - **coordinatorWait(Lokhttp3/internal/concurrent/TaskRunner;J)V**: Waits for the coordinator. - **execute(Ljava/lang/Runnable;)V**: Executes a Runnable. - **nanoTime()**: Returns the current nano time. ``` -------------------------------- ### PlayerView Constructors Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Constructors for creating instances of PlayerView with different configurations. ```APIDOC ## PlayerView Constructors ### Description These constructors allow you to create a `PlayerView` instance with varying levels of initialization. ### Methods - `PlayerView(Context context)` - `PlayerView(Context context, AttributeSet attrs)` - `PlayerView(Context context, AttributeSet attrs, int defStyleAttr)` ``` -------------------------------- ### Util Class Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt This section details various utility methods available in the androidx.media3.common.util.Util class for common media operations. ```APIDOC ## Util Class Methods This class provides a collection of static utility methods for common tasks related to media playback, format handling, and device information. ### Methods - **getApiLevelThatAudioFormatIntroducedAudioEncoding(int)**: Returns the API level at which a specific audio encoding was introduced. - **getAudioFormat(int, int, int)**: Creates an AudioFormat object. - **getAudioTrackChannelConfig(int)**: Retrieves the channel configuration for an audio track. - **getAvailableCommands(Player, Player.Commands)**: Gets the available commands for a player. - **getCountryCode(Context)**: Retrieves the country code of the device. - **getCurrentDisplayModeSize(Context)**: Gets the current display size. - **getCurrentDisplayModeSize(Context, Display)**: Gets the current display size for a specific display. - **getCurrentOrMainLooper()**: Returns the current or main Looper. - **getDisplaySizeV23(Display, Point)**: Gets the display size for API level 23 and above. - **getDrawable(Context, Resources, int)**: Retrieves a drawable resource. - **getMediaDurationForPlayoutDuration(long, float)**: Converts playout duration to media duration. - **getPcmFormat(int, int, int)**: Creates a PCM format. - **getPcmFrameSize(int, int)**: Calculates the frame size for PCM data. - **getPlayoutDurationForMediaDuration(long, float)**: Converts media duration to playout duration. - **getSystemLanguageCodes()**: Gets the system language codes. - **getSystemLocales()**: Gets the system locales. - **getSystemLocalesV24(Configuration)**: Gets the system locales for API level 24 and above. - **getTrackTypeString(int)**: Converts a track type integer to its string representation. - **getUtf8Bytes(String)**: Converts a string to UTF-8 bytes. - **inferContentType(Uri)**: Infers the content type from a URI. - **inferContentTypeForExtension(String)**: Infers the content type from a file extension. - **inferContentTypeForUriAndMimeType(Uri, String)**: Infers the content type from a URI and MIME type. - **intToStringMaxRadix(int)**: Converts an integer to a string with the maximum radix. - **isAutomotive(Context)**: Checks if the device is an automotive device. - **isEncodingLinearPcm(int)**: Checks if an audio encoding is linear PCM. - **isLocalFileUri(Uri)**: Checks if a URI points to a local file. - **isTv(Context)**: Checks if the device is a TV. - **msToUs(long)**: Converts milliseconds to microseconds. - **newSingleThreadExecutor(String)**: Creates a single-thread executor. - **normalizeLanguageCode(String)**: Normalizes a language code. - **nullSafeArrayConcatenation(Object[], Object[])**: Concatenates two arrays safely, handling nulls. - **nullSafeArrayCopy(Object[], int)**: Copies an array safely, handling nulls. - **postOrRun(Handler, Runnable)**: Posts a runnable to a handler or runs it directly. - **sampleCountToDurationUs(long, int)**: Converts sample count to duration in microseconds. - **scaleLargeTimestamp(long, long, long)**: Scales a large timestamp. - **scaleLargeTimestampsInPlace(long[], long, long)**: Scales large timestamps in place. - **scaleLargeValue(long, long, long, RoundingMode)**: Scales a large value. - **scaleLargeValueFallback(long, long, long, RoundingMode)**: Scales a large value with fallback. - **scaleLargeValuesInPlace(long[], long, long, RoundingMode)**: Scales large values in place. - **split(String, String)**: Splits a string by a delimiter. - **splitAtFirst(String, String)**: Splits a string at the first occurrence of a delimiter. - **usToMs(long)**: Converts microseconds to milliseconds. ``` -------------------------------- ### SemanticsPropertyKey Constructors Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Constructors for creating SemanticsPropertyKey instances. ```APIDOC ## SemanticsPropertyKey ### Description Constructors for creating SemanticsPropertyKey instances. ### Method N/A (Constructor) ### Parameters - **name** (String) - The name of the property key. - **defaultValue** (Function2, Unit) - The default value function. - **defaultValue** (Function2, Unit, Int, DefaultConstructorMarker) - The default value function with flags. - **initialValue** (Boolean) - The initial boolean value. - **initialValue** (Boolean, Function2, Unit) - The initial boolean value with a default value function. - **initialValue** (String) - The initial string value. ``` -------------------------------- ### BaseMediaSource Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for managing media sources, including preparation, information refresh, and release. ```APIDOC ## prepareSource ### Description Prepares the media source for playback. ### Method `prepareSource` ### Parameters - `MediaSourceCaller` (caller): The caller of the media source. - `TransferListener` (listener): Listener for transfer events. - `PlayerId` (playerId): The player's unique identifier. ## refreshSourceInfo ### Description Refreshes the source information with a new timeline. ### Method `refreshSourceInfo` ### Parameters - `Timeline` (timeline): The new timeline for the media source. ## releaseSource ### Description Releases the media source. ### Method `releaseSource` ### Parameters - `MediaSourceCaller` (caller): The caller releasing the media source. ## removeDrmEventListener ### Description Removes a DRM event listener. ### Method `removeDrmEventListener` ### Parameters - `DrmSessionEventListener` (listener): The DRM event listener to remove. ## removeEventListener ### Description Removes a media source event listener. ### Method `removeEventListener` ### Parameters - `MediaSourceEventListener` (listener): The media source event listener to remove. ``` -------------------------------- ### MediaSourceList Class Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Details on MediaSourceList constructors and methods for managing media sources. ```APIDOC ## MediaSourceList$MediaSourceAndListener Constructor ### Description Constructs a new MediaSourceAndListener object. ### Method `PL` ### Parameters - `source` (Landroidx/media3/exoplayer/source/MediaSource;) - Description - `listener` (Landroidx/media3/exoplayer/source/MediaSource$MediaSourceCaller;) - Description - `eventListener` (Landroidx/media3/exoplayer/MediaSourceList$ForwardingEventListener;) - Description ## MediaSourceList$MediaSourceHolder Constructor ### Description Constructs a new MediaSourceHolder object. ### Method `PL` ### Parameters - `source` (Landroidx/media3/exoplayer/source/MediaSource;) - Description - `isDynamic` (Z) - Description ## MediaSourceList$MediaSourceHolder Methods ### Description Methods for interacting with MediaSourceHolder, including retrieving timeline and unique identifier, and resetting. ### Methods - `getTimeline()`: Retrieves the timeline for the media source. - `getUid()`: Retrieves the unique identifier for the media source holder. - `reset(I)`: Resets the media source holder with a given index. ``` -------------------------------- ### Deploy Backend Server Source: https://github.com/android/tv-samples/blob/main/ReferenceAppKotlin/firebase/README.md Execute this command to deploy your backend server code to Firebase Cloud Functions. ```bash firebase deploy ``` -------------------------------- ### Format Processing and Codec Initialization Checks Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for processing output media format changes and checking codec initialization conditions. ```APIDOC ## processOutputMediaFormatChanged ### Description Processes a change in the output media format. ### Method `public void processOutputMediaFormatChanged()` ## readSourceOmittingSampleData ### Description Reads from the source, omitting sample data. ### Method `public boolean readSourceOmittingSampleData(int bufferSize)` ### Parameters - **bufferSize** (int) - The size of the buffer to read. ## shouldReinitCodec ### Description Determines if the codec needs to be reinitialized. ### Method `public boolean shouldReinitCodec()` ``` -------------------------------- ### TaskRunner Methods Source: https://github.com/android/tv-samples/blob/main/JetStreamCompose/jetstream/src/release/generated/baselineProfiles/baseline-prof.txt Methods for managing asynchronous tasks and queues within OkHttp. ```APIDOC ## TaskRunner ### Methods - **getBackend()**: Returns the TaskRunner's backend. - **kickCoordinator$(Lokhttp3/internal/concurrent/TaskQueue;)V**: Kicks the coordinator for a given TaskQueue. - **newQueue()**: Creates a new TaskQueue. - **runTask(Lokhttp3/internal/concurrent/Task;)V**: Executes a given Task. ```