This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
AudioTrack Read Examples
peter-majeed edited this page Jan 7, 2013
·
4 revisions
#AudioTrack Read calls All calls that are part of the Brightcove AudioTrack Read API are wrapped and available within the .NET-MAPI-Wrapper. It functions identically in most ways to the Brightcove Video Read API. You will find examples of some of the more common use cases below.
API calls are subject to the whims of internet connectivity, and may throw an exception for any number of reasons:
- The Brightcove API may be down or not functioning correctly.
- Network connectivity may be lost between your application and Brightcove.
- Invalid parameters passed to the API may result in an error message in the response JSON. The error message will be wrapped in a BrightcoveApiException and thrown so that it may be handled via normal .NET error handling mechanisms.
Although the examples shown here do not include try/catch blocks, in order to ensure that your app is as robust as possible make sure to try/catch all API calls.
See how to work with the BrightcoveApi object on the Getting Started page.
- Find all audio tracks in your account
- Find an audio track by ID
- Find an audio track by reference ID
- Find audio tracks by IDs
- Find audio tracks by reference IDs
- Find audio tracks by tags
- Find audio tracks by text
- Find recently modified audio tracks
// Get all audio tracks.
// Returns 1 page at a time, 1 result per page. In this case, it returns only the first page of results (one result).
// Results are sorted by creation date in descending order.
// Results only have the Id, Name, and ShortDescription populated.
BrightcoveItemCollection<BrightcoveAudioTrack> audioTracks = api.FindAllAudioTracks
(
1,
0,
SortBy.CreationDate,
SortOrder.Descending,
new string[] { "id", "name", "shortDescription" }
);
foreach (BrightcoveAudioTrack audioTrack in audioTracks)
{
// Process each audio track...
}
<a name="find-by-id" />
## Find an audio track by ID
```c#
// Instantiate an API object by using the provided factory
BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");
// If you know the id of the audio track in advance, you can search for it.
BrightcoveAudioTrack audioTrack = api.FindAudioTrackById(1234567890);
// If you know the reference id of the audio track in advance, you can search for it.
BrightcoveAudioTrack audioTrack = api.FindAudioTrackByReferenceId("test-audio-reference-id");
<a name="find-by-ids" />
## Find audio tracks by IDs
```c#
// Instantiate an API object by using the provided factory
BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");
// A list of known audio track IDs.
long[] ids = new long[] { 1234567890, 1234567891, 1234567892, 1234567893 };
BrightcoveItemCollection<BrightcoveAudioTrack> audioTracks = api.FindAudioTracksByIds(ids);
foreach (BrightcoveAudioTrack audioTrack in audioTracks)
{
// Process each audio track.
// Note: if any of the given IDs are not found in Brightcove's audio track repository,
// its place will be represented in the BrightcoveItemCollection by a null reference.
}
// A list of known audio track reference IDs.
string[] ids = new string[] { "test-0", "test-1", "test-2", "test-3" };
BrightcoveItemCollection<BrightcoveAudioTrack> audioTracks = api.FindAudioTracksByReferenceIds(ids);
foreach (BrightcoveAudioTrack audioTrack in audioTracks)
{
// Process each audio track.
// Note: if any of the given reference IDs are not found in Brightcove's audio track repository,
// its place will be represented in the BrightcoveItemCollection by a null reference.
}
<a name="find-by-tags" />
## Find audio tracks by tags
```c#
// Instantiate an API object by using the provided factory
BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");
// Finds all audio tracks on the first page, which contains 1 result,
// sorting by creation date in descending order, with only the Id,
// Name, and ShortDescription populated, that have both the "United States"
// and "2012" tags and have either of the "president" or "economy" tags.
BrightcoveItemCollection<BrightcoveAudioTrack> audioTracks = api.FindAudioTracksByTags
(
new string[] { "United States", "2012" },
new string[] { "president", "economy" },
1,
0,
SortBy.CreationDate,
SortOrder.Descending,
new string[] { "id", "name", "shortDescription" }
);
foreach (BrightcoveAudioTrack audioTrack in audioTracks)
{
// Process each audio track if any match the criteria you provided.
}
// Finds all audio tracks that match the word "Delano".
BrightcoveItemCollection<BrightcoveAudioTrack> audioTracks = api.FindAudioTracksByText("Delano");
foreach (BrightcoveAudioTrack audioTrack in audioTracks)
{
// Process each audio track if any match the criteria you provided.
}
<a name="find-modified-audio-tracks" />
## Find recently modified audio tracks
```c#
// Instantiate an API object by using the provided factory
BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");
// Finds all audio tracks that have been modified in the last two months.
BrightcoveItemCollection<BrightcoveAudioTrack> audioTracks = api.FindModifiedAudioTracks(DateTime.Now.AddMonths(-2));
foreach (BrightcoveAudioTrack audioTrack in audioTracks)
{
// Process each audio track if any match the criteria you provided.
}
More Examples