Stay organized with collections
Save and categorize content based on your preferences.
Attributes for audio programs depend on the type of the content. The program
type tells the system what metadata to expect so that the UI can be filled in
appropriately. Audio programs can be one of these types:
Use PreviewProgram.Builder
to build a program. You can read more about possible values for each field in
the Java documentation for each setter on the builder.
The following example shows how to use PreviewProgram.Builder:
PreviewProgram program = new PreviewProgram.Builder()
.setChannelId(channelId)
.setTitle(clip.getTitle())
.setDescription(clip.getDescription())
.setType(TvContractCompat.PreviewPrograms.TYPE_ALBUM)
// Set required attributes
.build();
The following table shows the attributes that can be assigned to each type of
audio program, and links to the corresponding setter in
PreviewProgram.Builder. Attributes marked ✔ are required; those marked (✔) are optional.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Audio program attributes\n\nAttributes for audio programs depend on the type of the content. The program\ntype tells the system what metadata to expect so that the UI can be filled in\nappropriately. Audio programs can be one of these types:\n\n- [`TYPE_TRACK`](/reference/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms#TYPE_TRACK())\n- [`TYPE_ALBUM`](/reference/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms#TYPE_ALBUM())\n- [`TYPE_ARTIST`](/reference/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms#TYPE_ARTIST())\n- [`TYPE_PLAYLIST`](/reference/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms#TYPE_PLAYLIST())\n- [`TYPE_STATION`](/reference/androidx/tvprovider/media/tv/TvContractCompat.PreviewPrograms#TYPE_STATION())\n\nUse [`PreviewProgram.Builder`](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder)\nto build a program. You can read more about possible values for each field in\nthe Java documentation for each setter on the builder.\n\nThe following example shows how to use `PreviewProgram.Builder`: \n\n PreviewProgram program = new PreviewProgram.Builder()\n .setChannelId(channelId)\n .setTitle(clip.getTitle())\n .setDescription(clip.getDescription())\n .setType(TvContractCompat.PreviewPrograms.TYPE_ALBUM)\n // Set required attributes\n .build();\n\nThe following table shows the attributes that can be assigned to each type of\naudio program, and links to the corresponding setter in\n`PreviewProgram.Builder`. Attributes marked ✔ are required; those marked (✔) are optional.\n\n| Attribute | Track | Album | Artist | Playlist | Station |\n|---------------------------------------------------------------------------------------------------------------------------------------------|-------|-------|--------|----------|---------|\n| [Author](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setAuthor(java.lang.String)) | (✔) | (✔) | | (✔) | |\n| [Availability](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setAvailability(int)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Channel ID](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setChannelId(long)) | ✔ | ✔ | ✔ | ✔ | ✔ |\n| [Content ID](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setContentId(java.lang.String)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Duration](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setDurationMillis(int)) | ✔ | | | | |\n| [Genre](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setGenre(java.lang.String)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Intent URI](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setIntentUri(android.net.Uri)) | ✔ | ✔ | ✔ | ✔ | ✔ |\n| [Interaction Count](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setInteractionCount(long)) | | | (✔) | (✔) | (✔) |\n| [Interaction Type](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setInteractionType(int)) | | | (✔) | (✔) | (✔) |\n| [Internal Provider ID](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setInternalProviderId(java.lang.String)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Live](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setLive(boolean)) | | | | | (✔) |\n| [Logo URI (\\*)](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setLogoUri(android.net.Uri)) | | | | (✔) | |\n| [Logo Content Description (\\*)](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setLogoContentDescription(java.lang.String)) | | | | (✔) | |\n| [Offer Price](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setOfferPrice(java.lang.String)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Poster Art Aspect Ratio](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setPosterArtAspectRatio(int)) | ✔ | ✔ | ✔ | ✔ | ✔ |\n| [Poster Art URI](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setPosterArtUri(android.net.Uri)) | ✔ | ✔ | ✔ | ✔ | ✔ |\n| [Preview Audio URI](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setPreviewAudioUri(android.net.Uri)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Preview Video URI](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setPreviewVideoUri(android.net.Uri)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Release Date](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setReleaseDate(java.lang.String)) | (✔) | (✔) | | | |\n| [Short Description](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setDescription(java.lang.String)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Starting Price](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setStartingPrice(java.lang.String)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Thumbnail Aspect Ratio](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setThumbnailAspectRatio(int)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Thumbnail URI](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setThumbnailUri(android.net.Uri)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Title](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setTitle(java.lang.String)) | ✔ | ✔ | ✔ | ✔ | ✔ |\n| [Video Height](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setVideoHeight(int)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Video Width](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setVideoWidth(int)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n| [Weight](/reference/androidx/tvprovider/media/tv/PreviewProgram.Builder#setWeight(int)) | (✔) | (✔) | (✔) | (✔) | (✔) |\n\n| **(\\*) Notes:** LOGO_CONTENT_DESCRIPTION is required when LOGO_URI is used."]]