Step 1: Load Your Media Feed
The heart of your app is the media feed. This feed contains your video content, including titles, descriptions, thumbnails, and other details for each media object.
Since different media feeds have different structures (with different terms for the various properties or elements), Fire App Builder queries your media feed for the needed components and converts the queried result to a structure and terminology that aligns with Fire App Builder's content model. Using a query syntax (rather than requiring all users to conform to pre-existing specification), gives you more flexibility to use your existing feed in Fire App Builder.
Before you write these queries (specifying them in categories and content recipes), you must first load your media feed following the instructions here.
Two Fire App Builder components are used to load and configure the media feed: DataLoader and DynamicParser. The DataLoader module loads the data feed, and DynamicParser configures the structure and key values of the feed so that Fire App Builder can read it. Rather than working in Java, you configure both of these modules through JSON files. The Java code will read from the values in various JSON files.
- Video Tutorial
- Types of Feeds
- Loading a Static Feed That Is Packaged with Your App
- Other Options to Load Your Feed
- Next Steps
Video Tutorial
See this video tutorial for a high-level overview about configuring your media feed in Fire App Builder:
Types of Feeds
You can load the following types of feeds:
- Open Feeds: Feeds that are openly accessible without a token
- Token-based Feeds: Feeds that require a token to access
Use these instructions if you publish your media details in a web feed that is open and unrestricted, that is, no token is required to access the media.
-
Open the DataLoadManagerConfig.json file (located in app > assets > configurations in the Android view).
Tip: In Android Studio, instead of browsing folders, you can press Shift key twice and then type the file name to quickly find a file. - Leave the value for the data_downloader.impl option as is:
com.amazon.dataloader.datadownloader.BasicHttpBasedDataDownloader
. - If desired, you can update the options for these two properties:
is_cache_manager_enabled
: Whether your feed is cached in the app. Caching your feeds speeds up screen loading with the media retrieved, but the cache will not reflect the latest updates to the feed until the data loader is updated or until the feed is expired. Options aretrue
orfalse
. Usually, leave this at the default (true
).-
data_updater.duration
: The interval (in seconds) when the data loader refreshes your feed and retrieves the latest updates. When the data loader updates, the cache gets purged. The default is 14400 seconds, or 4 hours. Usually, leave this at the default (14400
).Note: Each time users start the app, your app's cache is automatically purged and the feed is refreshed.
-
Open the BasicHttpBasedDownloaderConfig.json file (located in app > assets > configurations) and ensure the value for
url_generator_impl
is as follows:{ "url_generator_impl" : "com.amazon.dataloader.datadownloader.BasicFileBasedUrlGenerator" }
-
Open the BasicFileBasedUrlGeneratorConfig.json file (located in app > assets > configurations) and verify the contents matches the code below. This file specifies the location of the
url_file
that will contain your media feed. To make things easiest, leave the file name as the default:{ "url_file" : "urlFile.json" }
-
Open the urlFile.json (located in app > assets) and list your media feed URLs, replacing the default Lightcast feed with your own feed:
{ "urls": [ "http://www.lightcast.com/api/firetv/channels.php?app_id=249&app_key=gtn89uj3dsw&action=channels_videos" ] }
If you have multiple feeds, separate them with commas:
{ "urls": [ "http://www.example.com/feed1.json", "http://www.example.com/feed2.json" ] }
Use these instructions if you publish your media details in a web feed whose access is restricted by a token.
-
Open the DataLoadManagerConfig.json file (located in app > assets > configurations).
Tip: In Android Studio, instead of browsing folders, you can press Shift key twice and then type the file name to quickly find a file. - Leave the value for the data_downloader.impl option as is:
com.amazon.dataloader.datadownloader.BasicHttpBasedDataDownloader
. - If desired, you can update the options for these two properties:
is_cache_manager_enabled
: Whether your feed is cached in the app. Caching your feeds speeds up screen loading with the media retrieved, but the cache will not reflect the latest updates to the feed until the data loader is updated or until the feed is expired. Options aretrue
orfalse
. Usually, leave this at the default (true
).-
data_updater.duration
: The interval (in seconds) when the data loader refreshes your feed and retrieves the latest updates. When the data loader updates, the cache gets purged. The default is 14400 seconds, or 4 hours. Usually, leave this at the default (14400
).Note: Each time users start the app, your app's cache is automatically purged and the feed is refreshed.
-
Open the BasicHttpBasedDownloaderConfig.json file (located in app > assets > configurations) and change the value from
com.amazon.dataloader.datadownloader.BasicFileBasedUrlGenerator
tocom.amazon.dataloader.datadownloader.BasicTokenBasedUrlGenerator
:{ "url_generator_impl": "com.amazon.dataloader.datadownloader.BasicTokenBasedUrlGenerator" }
-
Create a file inside app > assets > configurations called BasicTokenBasedUrlGeneratorConfig.json. Inside the file, create a JSON object that includes two key-value pairs as follows:
{ "base_url" : "http://yourcompany.com/mediafeed?id=$$token$$", "token_generation_url" : "http://yourcompany.com/url_to_generate_token" }
-
Customize the values for both
base_url
andtoken_generation_url
with your company's actual values.The
base_url
is the URL to your media feed. Thetoken_generation_url
contains a link to a URL that generates the token to access the URL.In this example, the token is inserted into the URL with
$$token$$
. (Your media URL may insert the token in some other way. If so, adjust the placement of the$$token$$
where it should appear.)The parameters from this BasicTokenBasedUrlGeneratorConfig.json file (
base_url
andtoken_generation_url
) get passed to theBasicTokenBasedUrlGenerator
class (located in DataLoader > java > com.amazon.dataloader). TheBasicTokenBasedUrlGenerator
class constructs a URL which is then consumed by theBasicHttpBasedDataDownloader
class. TheBasicHttpBasedDataDownloader
class gets and retrieves the content from the URL.
Loading a Static Feed That Is Packaged with Your App
For testing purposes, you can also load a static feed that is packaged within your app. A static feed is one that exists only in your app and isn't updated outside of your app. You wouldn't normally use a feed like this, since you wouldn't be able to update the feed without resubmitting a new version of your app. Hence this would be done for testing purposes only. To load a static feed that is packaged inside your app, expand the details below:
Other Options to Load Your Feed
If none of these options work for you to load your feed, you can write your own data loader by adding a class in the DataLoader
folder that implements the Dataloader
interface. Additionally, if your feed is generated from a REST endpoint, you will have to write your own data downloader.
Next Steps
Loading the feed is just the first step. You have to help Fire App Builder identify the categories and content in your feed. See Recipe Configuration Overview.
Last updated: Apr 06, 2017