Skip to content

Helper for setting MediaBrowserServiceCompat for android-auto, automative and wearables

License

Notifications You must be signed in to change notification settings

chaimPaneth/react-native-android-media-browser

Repository files navigation

react-native-android-media-browser

A React Native module that provides a Media Browser Service for Android, allowing you to create a custom media browsing experience for Android Auto and Android Automotive OS.

Installation

  1. Install the library using npm or yarn: npm install react-native-android-media-browser or yarn add react-native-android-media-browser.

  2. Link the native module using react-native link (if you're using a version of React Native <= 0.59): react-native link react-native-android-media-browser.

Usage

  1. Import the MediaBrowser module in your JavaScript code:
import MediaBrowser, {
    CONTENT_STYLE_LIST_ITEM,
    CONTENT_STYLE_GRID_ITEM,
    CONTENT_STYLE_CATEGORY_LIST_ITEM,
    CONTENT_STYLE_CATEGORY_GRID_ITEM
} from 'react-native-android-media-browser';
  1. Define your media items hierarchy:
const mediaItems = [
    {
        id: "ROOT",
        children: [
            {
                id: "Home",
                title: "Home",
                subTitle: "Welcome home!",
                icon: "home.png",
                browsableStyle: CONTENT_STYLE_GRID_ITEM,
                playableStyle: CONTENT_STYLE_LIST_ITEM,
                playableOrBrowsable: "BROWSABLE",
                children: [
                    // ... more nested media items
                ],
            },
            // ... other top-level media items
        ],
    },
];
  1. Set the media items hierarchy in the MediaBrowser module:
MediaBrowser.setMediaItems(mediaItems);
  1. You can also add, delete, and update media items:
MediaBrowser.addMediaItem(item);
MediaBrowser.deleteMediaItem(itemId);
MediaBrowser.updateMediaItem(item);

License

MIT

About

Helper for setting MediaBrowserServiceCompat for android-auto, automative and wearables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published