// Media Browse UI enabledcontrols.setBrowseContent(BrowseContent);console.log(controls.getSafeAreaHeight());// 338px on Google Nest Hub// Media Browse UI disabledcontrols.setBrowseContent(null);console.log(controls.getSafeAreaHeight());// 408px on Google Nest Hub
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eCast Media Browse (CMB) enhances smart displays with a browsing experience for audio and video content, using standardized templates populated by developers.\u003c/p\u003e\n"],["\u003cp\u003eUsers can access CMB through two entry points: during playback (In-player browse) and while the Web Receiver is idle (Landing page browse).\u003c/p\u003e\n"],["\u003cp\u003eDevelopers populate templates with content data, using In-player browse for related or playlist items and Landing page browse to highlight new or live content.\u003c/p\u003e\n"],["\u003cp\u003eCMB is enabled by calling \u003ccode\u003esetBrowseContent\u003c/code\u003e with content data and can be customized with titles, images, durations, and subtitles for each item.\u003c/p\u003e\n"],["\u003cp\u003eWhen a user selects an item, the Web Receiver sends a \u003ccode\u003eLOAD\u003c/code\u003e message, allowing the application to initiate playback based on the item's properties.\u003c/p\u003e\n"]]],["Cast Media Browse (CMB) allows smart display users to explore audio/video content via two entry points: In-player (during playback) and Landing Page (in idle state). Developers populate standardized templates with content data using `setBrowseContent`, with a maximum of 30 items. They can customize the UI title and items (title, subtitle, duration, image) using `BrowseContent` and `BrowseItem` and also choose the image's aspect ratio. Removing CMB uses `setBrowseContent(null)`. User item selection triggers a `LOAD` message with item details.\n"],null,["# Media Browse\n\nCast Media Browse (CMB) is a feature that lets smart display users\ndiscover and engage with your audio or video content catalog. CMB does so by\nenhancing the Web Receiver with a streamlined browsing experience that is\nspecially tuned for smart displays.\n\nCMB defines standardized templates that deliver a consistent browsing experience\nthat follows smart display UI conventions. Developers supply data to populate\nthese standardized templates. Templates support both audio and video content or\na mix of both.\n\nEntry points\n------------\n\nThere are two entry points for CMB, from which a user can browse and select\ncontent using touch or voice control.\n\n### In-player browse\n\nSwipe up during playback to choose from a list of application-supplied content:\n\n*Video*\n\n*Audio*\n\n### Landing page browse\n\nWhen a Web Receiver with the `cast-media-player` element is running on Smart\nDisplays, it shows CMB while in the IDLE state.\n\n*Video and Audio*\n\nPopulating content\n------------------\n\nDevelopers are responsible for populating the template for each entry point with\ndata for each content item. The content used to populate In-Player Browse can be\ndifferent than the content used to populate Landing Page Browse.\n\nUse In-Player Browse to display items that relate to the content a user is\ncurrently playing, or items of a playlist. Live TV providers could also use this\nentry point to populate a list of channels for easy access.\n\nUse Landing Page Browse to raise awareness of new original content, content that\nis currently live, or content that might be of further interest to your user.\n| **Warning:** To prevent performance issues, the maximum Media Browse item count is 30 items.\n\nEnable Media Browse\n-------------------\n\nProvide a list of media contents for browsing by calling [`setBrowseContent`](/cast/docs/reference/web_receiver/cast.framework.ui.Controls#setBrowseContent): \n\n```\nconst controls = cast.framework.ui.Controls.getInstance();\ncontrols.setBrowseContent(BrowseContent);\n```\n\nThe Media Browse UI is updated immediately after calling this method.\n\n### Safe area height\n\nWhen CMB is enabled, the height of the Cast SDK UI safe area changes, and you\nmight need to update your existing Web Receiver UI. Use\n[`getSafeAreaHeight`](/cast/docs/reference/caf_receiver/cast.framework.ui.Controls#getSafeAreaHeight)\nto determine the height of the safe area. \n\n```scilab\n// Media Browse UI enabled\ncontrols.setBrowseContent(BrowseContent);\nconsole.log(controls.getSafeAreaHeight()); // 338px on Google Nest Hub\n\n// Media Browse UI disabled\ncontrols.setBrowseContent(null);\nconsole.log(controls.getSafeAreaHeight()); // 408px on Google Nest Hub\n```\n\nRemove Media Browse\n-------------------\n\nTo remove the Media Browse UI, use `null` with `setBrowseContent`: \n\n```\ncontrols.setBrowseContent(null);\n```\n\nCustomize Media Browse\n----------------------\n\n### Browsing content\n\nUse\n[`BrowseContent`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseContent)\nto customize the title of the Media Browse UI and update items:\n\n\u003e A. [`BrowseContent.title`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseContent#title)\n\u003e\n\u003e B. [`BrowseContent.items`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseContent#items)\n\nUse\n[`BrowseItem`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseItem)\nto display title, subtitle, duration, and image for each item in the Media\nBrowse UI:\n\n\u003e A. [`BrowseItem.image`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseItem#image)\n\u003e\n\u003e B. [`BrowseItem.duration`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseItem#duration)\n\u003e\n\u003e C. [`BrowseItem.title`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseItem#title)\n\u003e\n\u003e D. [`BrowseItem.subtitle`](/cast/docs/reference/caf_receiver/cast.framework.ui.BrowseItem#subtitle)\n\n### Aspect ratio\n\nUse [`targetAspectRatio`](/cast/docs/reference/web_receiver/cast.framework.ui.BrowseContent#targetAspectRatio)\nto select the best aspect ratio for your image assets. Three aspect ratios are\nsupported by the Web Receiver SDK:\n\n| Aspect Ratio | Example |\n|---------------------|---------|\n| `SQUARE_1_TO_1` | |\n| `PORTRAIT_2_TO_3` | |\n| `LANDSCAPE_16_TO_9` | |\n\n### Messages\n\nWhen a user selects one of the items from the Media Browse UI, the Web Receiver\nSDK sends a `LOAD` message to the application according to\nthe values of the selected `BrowseItem`.\n\nSample code\n-----------\n\n const controls = cast.framework.ui.Controls.getInstance();\n\n const item1 = new cast.framework.ui.BrowseItem();\n item1.title = 'Title 1';\n item1.subtitle = 'Subtitle 1';\n item1.duration = 300;\n item1.imageType = cast.framework.ui.BrowseImageType.MUSIC_TRACK;\n item1.image = new cast.framework.messages.Image('1.jpg');\n item1.entity = 'example://gizmos/1';\n\n const item2 = new cast.framework.ui.BrowseItem();\n item2.title = 'Title 2';\n item2.subtitle = 'Subtitle 2';\n item2.duration = 100;\n item2.imageType = cast.framework.ui.BrowseImageType.MUSIC_TRACK;\n item2.image = new cast.framework.messages.Image('2.jpg');\n item2.entity = 'example://gizmos/2';\n\n const items = [item1, item2];\n\n const browseContent = new cast.framework.ui.BrowseContent();\n browseContent.title = 'Up Next';\n browseContent.items = items;\n\n playerDataBinder.addEventListener(\n cast.framework.ui.PlayerDataEventType.MEDIA_CHANGED,\n (e) =\u003e {\n // Media browse\n controls.setBrowseContent(browseContent);\n });\n\n playerManager.setMessageInterceptor(\n cast.framework.messages.MessageType.LOAD, loadRequestData =\u003e {\n if (loadRequestData.media && loadRequestData.media.entity) {\n // Load by entity\n loadRequestData.media.contentId = entityToId(loadRequestData.media.entity);\n loadRequestData.media.contentUrl = entityToUrl(loadRequestData.media.entity);\n }\n return loadRequestData;\n });"]]