Skip to main content

Function: capRootTabs()

function capRootTabs(items: readonly BrowseItem[], limit?: number): RootTabs;

Defined in: packages/media-session/src/browse.ts:262

Enforce the two rules every car's root has, in one place for both platforms.

  1. Browsable only. Android Auto's root supports FLAG_BROWSABLE and nothing else — a playable root entry is not "a shortcut that plays", it is an entry the car may drop or hide. CarPlay's root is a tab bar of templates, which a playable leaf cannot be either.
  2. At most MAX_ROOT_TABS.

Dropping is right and rejecting the whole root is not: a fifth tab must not cost the user the four that fit. But it is never silent — every caller feeds rejected to the session-error channel as browseRootRejected (ARCHITECTURE §27).

Parameters

ParameterTypeDefault valueDescription
itemsreadonly BrowseItem[]undefined-
limitnumberMAX_ROOT_TABSthe effective cap; defaults to MAX_ROOT_TABS. Android passes the browser's own EXTRAS_KEY_ROOT_CHILDREN_LIMIT when it is smaller.

Returns

RootTabs