Replay Playback
Overview
Feed.fm Replay is a product that allows clients to select songs from a catalog of independent label content to create a playlist that plays in the same order every time it's heard alongside your content.
It is designed for those who want to easily incorporate music into apps or content soundtracks and stream globally. It's an ideal solution for anyone tired of navigating extensive production music catalogs or settling for royalty-free options, offering a quicker way to access quality music that matches any vibe.
Replay stations are an extention of First play stations. The main difference being that replay station can be replayed multiple times in the exact same order unlike first play which can only be played back in a specific order once.
There are two ways to start playback of a Replay station:
searchForAndSetActiveStation(iOS SDK 5.8.0+, Android SDK 7.1.0+) — find the station, set it as the active station, and begin buffering audio in a single network request. This is the recommended approach.setActiveStationwith anadvancevalue — pick a specific station from the station list yourself and start playback at a given offset into the station.
Finding and playing a Replay station with searchForAndSetActiveStation
The example below searches for a Replay station named "Replay Station X", sets it as the
active station, and starts playback from the beginning of the station (advance = 0) as
soon as audio is buffered. See the Station Search recipe for
full details on search queries, filters, and error handling.
- Kotlin
- Swift
- Objective-C
val searches = listOf(
StationSearch(
type = StationSearchType.REPLAY,
at = 0, // play the station from the beginning
filter = mapOf("name" to "Replay Station X")
)
)
player.searchForAndSetActiveStation(
stationSearches = searches,
prepareToPlay = true,
callback = object : SearchAndSetActiveStationCallback {
override fun onSuccess(station: Station, play: Play) {
// "Replay Station X" is now active and audio is buffered
player.play()
}
override fun onError(error: FeedFMError) {
// no Replay station matched the search
}
}
)
let queries: [FMStationSearchQuery] = [
.replay(withAdvance: 0, // play the station from the beginning
filter: ["name": "Replay Station X"])
]
let player = FMAudioPlayer.shared()
player.search(
forAndSetActiveStation: queries,
searchTimeoutMs: nil, // defaults to 2000ms
prepareToPlay: true,
prepareTimeoutMs: nil // defaults to 5000ms
) { audioItem, error in
if let error {
// no Replay station matched the search
print("station search failed: \(error)")
return
}
// "Replay Station X" is now active and audio is buffered
player.play()
}
FMStationSearchQuery *query =
[FMStationSearchQuery replayWithAdvance:0 // play the station from the beginning
filter:@{ @"name": @"Replay Station X" }];
FMAudioPlayer *player = [FMAudioPlayer sharedPlayer];
[player searchForAndSetActiveStation:@[ query ]
searchTimeoutMs:nil // defaults to 2000ms
prepareToPlay:YES
prepareTimeoutMs:nil // defaults to 5000ms
completion:^(FMAudioItem *_Nullable audioItem,
NSError *_Nullable error) {
if (error) {
// no Replay station matched the search
NSLog(@"station search failed: %@", error);
return;
}
// "Replay Station X" is now active and audio is buffered
[player play];
}];
Because Replay stations can be played back any number of times, the same search succeeds
every time it is made — unlike a First Play station, which stops matching once the client
has played through it. To start playback somewhere other than the beginning of the station,
pass the number of seconds to skip as the advance (iOS) / at (Android) value.
Selecting a specific station and starting at an offset with setActiveStation
If you'd rather pick the station yourself — retrieve it
from the player's station list and pass it to setActiveStation along with the number of
seconds to advance into the station. Pass an advance of 0 to play the station from the
beginning.
- Kotlin
- Swift
- Objective-C
val station = player.stationList.getStationWithOption("uuid", "my-unique-replay-station-id")
if (station != null) {
// begin playback 90 seconds into the station;
// pass advanceBy = 0f to play from the beginning
player.setActiveStation(station = station, withCrossfade = false, advanceBy = 90f)
player.play()
}
let player = FMAudioPlayer.shared()
if let station = player.stationList.getStationWithOptionKey("uuid",
value: "my-unique-replay-station-id" as NSString) {
// begin playback 90 seconds into the station;
// pass an advance of 0 to play from the beginning
player.setActiveStation(station, withAdvance: 90)
player.play()
}
FMAudioPlayer *player = [FMAudioPlayer sharedPlayer];
FMStation *station = [player.stationList getStationWithOptionKey:@"uuid"
Value:@"my-unique-replay-station-id"];
if (station != nil) {
// begin playback 90 seconds into the station;
// pass an advance of 0 to play from the beginning
[player setActiveStation:station withAdvance:90];
[player play];
}