AdaptrAudioPlayer Class Reference
Inherits from | NSObject |
---|---|
Declared in | AdaptrAudioPlayer.h |
Overview
The SDK centers around a singleton instance of this AdaptrAudioPlayer
class, which
has simple methods to control music playback (play
, pause
, skip
). The
AdaptrAudioPlayer
holds lists of Station
objects (stationList
and localOfflineStationList
), one of which is always
considered the active station (activeStation
). Once music playback has begun, there
is a current song (currentSong
).
Typical initialization and setup is as follows:
As early as you can in your app’s lifecycle (preferably in your AppDelegate
or initial ViewController
) call
[AdaptrAudioPlayer setclientToken:@"demo" secret:@"demo"]
to asynchronously contact the feed.fm servers, validate that the client is in a location that can legally stream music, and kick of a thread to retrieve a list of available streaming music stations.
There are a number of sample credentials you can use to assist in testing your app out. Use one of the following strings for your token and secret to get the desired behavior:
- ‘demo’ - 3 simple stations with no skip limits
- ‘badgeo’ - feed.fm will treat this client as if it were accessing from outside the US
- ‘counting’ - a station that just plays really short audio clips of a voice saying the numbers 0 through 9
To receive notice that music is available or not available, use the
whenAvailable:notAvailable:
method call, which is guaranteed to call
only one of its arguments as soon as music is deemed available or not:
AdaptrAudioPlayer *player = [AdaptrAudioPlayer sharedPlayer];
[player whenAvailable:^{
NSLog(@"music is available!");
// .. do something, now that you know music is available
} notAvailable: ^{
NSLog(@"music is not available!");
// .. do something, like leave music button hidden
}];
Because music may not be available to this particular client (due to lack of network connectivity or geographic restrictions), we recommend you leave music functionality hidden by default, and reveal it only when confirmation is returned.
Once music is available, use the play
, pause
, skip
methods to
control playback. The stationList
and localOfflineStationList
properties
will contain lists of stations the user can switch to with the setActiveStation:
and
setActiveStation:withCrossfade:
calls.
// pick the station to play music from
Station *station = [player.stationList getStationWithOptionKey: @"genre" Value: @"HipHop"];
[player setActiveStation:station withCrossfade:NO];
// when you have set the station that is about to begin playback, you
// can optionally call prepareToPlay first so playback is immediate upon
// calling 'play'
[player prepareToPlay];
// begin playback!
// (if you called 'prepareToPlay', then you should first wait for
// an AdaptrAudioPlayerMusicQueuedNotification notification to be guaranteed
// that playback will start immediately on this call, with no intervening
// network requests)
[player play]
Offline music can be retrieved by selecting a station in the
remoteOfflineStationList
and passing it to downloadAndSyncStation:forTargetMinutes:withDelegate
.
That will cause the contents of the station to be downloaded onto the device
(or updated with new music, if the station was already downloaded and new
music is available), and a new Station
entry in localOfflineStationList
that can be passed to setActiveStation
.
The AdaptrAudioPlayer
registers with iOS so that
playback can be paused, skipped, liked, and disliked via the lock screen.
Additionally, iOS will display on the lock screen whatever image
you’ve assigned via [AdaptrAudioPlayer setLockScreenImage:]
.
The ‘prepareToPlay’ method can be called before playback begins and when the client knows that the current station will immediately be played next. This call is primarily useful when you want music to begin playback immediately upon a call to play, with no intervening network requests.
The AdaptrAudioPlayer
generates events that can be hooked into
whatever analytics service your app uses. Just have an object in your app
(your AppDelegate
is a good choice) implement the AdaptrAudioPlayerLogger
protocol. You just need to implement two
methods: logEvent:
and logEvent:withParameters:
,
and assign the object to [FeedMedia sharedPlayer].logger
.
For assistance with building music player UI, check out the UI library documentation and check out our demo app:
Setup
+ setClientToken:secret:
This method kicks off asynchronous initialization of the library and communication with the feed.fm servers. This call should be made as early as possible in the lifecycle of the app.
+ (void)setClientToken:(nonnull NSString *)token secret:(nonnull NSString *)secret
Parameters
token |
public authentication token. Use |
---|---|
secret |
private authentication token. Use |
Declared In
AdaptrAudioPlayer.h
+ sharedPlayer
There is only one global AdaptrAudioPlayer
instance, and it
is available via this static property.
+ (nonnull AdaptrAudioPlayer *)sharedPlayer
Declared In
AdaptrAudioPlayer.h
+ setBaseUrl:
Change the base url of Api For Internal testing only
+ (void)setBaseUrl:(NSString *_Nonnull)url
Declared In
AdaptrAudioPlayer.h
– whenAvailable:notAvailable:
Call one of the two callbacks as soon as we know music is available for playback. One of these two blocks is guaranteed to be called, and only one call will ever be made. Just before the onAvailable callback is made, the list of available stations is fully populated.
- (void)whenAvailable:(nonnull void ( ^ ) ( void ))onAvailable notAvailable:(nonnull void ( ^ ) ( void ))onNotAvailable
Parameters
onAvailable |
called when music becomes or already is available |
---|---|
onNotAvailable |
called when we determine music is not available |
Discussion
Note that the callbacks are only made after attempting to contact the Feed.fm servers, even if local offline music is available while waiting for a response. If the player is unable to contact the Feed.fm servers or they respond that no streaming music is available, but there is local offline music, then the onAvailable callback will be called.
If the player has already contacted (or failed to contact) the feed.fm servers, then one of the two calls passed callbacks will be called immediately, before this method returns.
Declared In
AdaptrAudioPlayer.h
– updateSession:
Called when there is need to update the stationlist from server. This method can be called periodically for long running apps that do not quit for multiple days If a new nession is not available then no callback will be recived
- (void)updateSession:(nonnull void ( ^ ) ( void ))onUpdatedSessionAvailable
Parameters
onUpdatedSessionAvailable |
called when session is refreshed |
---|
Declared In
AdaptrAudioPlayer.h
Playback Controls
– prepareToPlay
Starts asynchronous loading of the first song in the active station
so that a future call to play
will start music instantaneously.
This action runs asynchronously and, when it completes, triggers
an AdaptrAudioPlayerPreCachingCompleted
notification.
- (void)prepareToPlay
Declared In
AdaptrAudioPlayer.h
– play
Starts retrieval and playback of music in the active station.
- (void)play
Declared In
AdaptrAudioPlayer.h
– playAudioItem:
Start playback of specific song. This method only works with on-demand stations.
- (void)playAudioItem:(nonnull Audiofile *)audioItem
Parameters
audioItem |
the audio item to immediately play |
---|
Declared In
AdaptrAudioPlayer.h
– stop
Stops music playback and discards any cached audio.
- (void)stop
Declared In
AdaptrAudioPlayer.h
– skip
Asynchronously request that the player skip the current song. If the
request is successful, the current song will stop and the next will
begin. If not, an AdaptrAudioPlayerSkipFailedNotification
will be posted
to the default notification center and the current song will continue
playback.
- (void)skip
Declared In
AdaptrAudioPlayer.h
– like
Calls likeAudioItem:
with the currently playing song
- (void)like
See Also
Declared In
AdaptrAudioPlayer.h
– likeAudioItem:
Marks the specified song as ‘liked’. Updates the [Audiofile liked]
and [Audiofile disliked]
properties.
- (void)likeAudioItem:(nonnull Audiofile *)audioItem
Parameters
audioItem |
the audio item that is to be liked. If null, then the currently active audio item will be liked. |
---|
Discussion
This triggers an AdaptrAudioPlayerLikeStatusChangeNotification
notification
with a userInfo dictionary that contains the audioItem
object indexed by AudiofileKey
.
See Also
Declared In
AdaptrAudioPlayer.h
– dislike
Calls dislikeAudioItem:
with the currently playing song
- (void)dislike
See Also
Declared In
AdaptrAudioPlayer.h
– dislikeAudioItem:
Marks the specified song as ‘disliked’. Updates the [Audiofile liked]
and [Audiofile disliked]
properties.
- (void)dislikeAudioItem:(nonnull Audiofile *)audioItem
Parameters
audioItem |
the audio item that is to be disliked. If null, then the currently active audio item will be disliked. |
---|
Discussion
This triggers an AdaptrAudioPlayerLikeStatusChangeNotification
notification
with a userInfo dictionary that contains the audioItem
object indexed by AudiofileKey
.
See Also
Declared In
AdaptrAudioPlayer.h
– unlike
Calls unlikeAudioItem:
with the currently playing song
- (void)unlike
See Also
Declared In
AdaptrAudioPlayer.h
– unlikeAudioItem:
Marks the specified song as neither ‘liked’ nor ‘disliked’. Updates the [Audiofile liked]
and [Audiofile disliked]
properties.
- (void)unlikeAudioItem:(nonnull Audiofile *)audioItem
Parameters
audioItem |
the audio item that is to be unliked. If null, then the currently active audio item will be unliked. |
---|
Discussion
This triggers an AdaptrAudioPlayerLikeStatusChangeNotification
notification
with a userInfo dictionary that contains the audioItem
object indexed by AudiofileKey
.
See Also
Declared In
AdaptrAudioPlayer.h
– getClientId
Get currently Active ClientID
- (nullable NSString *)getClientId
Declared In
AdaptrAudioPlayer.h
– setClientId:
Sets a previously generated clientid to be the active id.
- (void)setClientId:(nonnull NSString *)cid
Parameters
cid |
previously generated client id |
---|
Declared In
AdaptrAudioPlayer.h
– createNewClientId
Asynchronously generate a new client id for a new user.
When this request is complete a NSNotification AdaptrAudioPlayerNewClientIdAvailable
is triggered
with userInfo dictionary that contains the clientid
- (void)createNewClientId
See Also
Declared In
AdaptrAudioPlayer.h
– setDefaultControlDelegate
Internal Method
- (void)setDefaultControlDelegate
Declared In
AdaptrAudioPlayer.h
– setPlayerControlDelegate:
Internal Method
- (void)setPlayerControlDelegate:(id<MixingAudioPlayer> _Nonnull)newPlayerControlDelegate
Declared In
AdaptrAudioPlayer.h
autoNetworkRetryEnabled
Enable/Disable auto retrying of network failures. If network disappears and this option in enabled, player will wait until network is restored and resume music playback, insted of shutting down. This option must be set before setClientToken is called. By default this option is set to true. If this opiton is set and setClientToken call fails due to network failure the SDK will call onUnAvailable but as network is restored OnAvailable will be automatically called again.
@property (class, nonatomic) BOOL autoNetworkRetryEnabled
Declared In
AdaptrAudioPlayer.h
Playback Status
playbackState
Current player state. As this state changes, an AdaptrAudioPlayerPlaybackStateDidChangeNotification
is triggered with the default notification center.
@property (nonatomic, readonly) AdaptrAudioPlayerPlaybackState playbackState
Declared In
AdaptrAudioPlayer.h
currentItem
The currently playing or paused song, or null if there is not one.
@property (nonatomic, readonly, nullable) Audiofile *currentItem
Declared In
AdaptrAudioPlayer.h
currentPlaybackTime
The elapsed playback time of the current item.
@property (nonatomic, readonly) NSTimeInterval currentPlaybackTime
Declared In
AdaptrAudioPlayer.h
currentItemDuration
Indicates the duration of the current item.
@property (nonatomic, readonly) NSTimeInterval currentItemDuration
Declared In
AdaptrAudioPlayer.h
currentPlaybackRate
The current rate of playback. Slow/fast play is not supported, so this will always be 0.0 or 1.0
@property (nonatomic, readonly) float currentPlaybackRate
Declared In
AdaptrAudioPlayer.h
canSkip
If false, then the user may not skip the currently playing
song. If true, the user may be able to skip the current song,
but the server will be queried and possibly reject the request.
This property is updated every time a new song
starts playback or after a failed skip attempt, and a
AdaptrAudioPlayerSkipStatusNotification notification
is sent any
time this value changes.
@property (readonly) BOOL canSkip
See Also
Declared In
AdaptrAudioPlayer.h
playHistory
This array holds all the Audiofiles that the user has heard since playback started, including the currently playing song. As new items start playback, they are appended to this array.
@property (nonatomic, readonly, nonnull) NSMutableArray<Audiofile*> *playHistory
Discussion
This history currently does not include songs from past sessions.
Declared In
AdaptrAudioPlayer.h
Playback options
secondsOfCrossfade
The number of seconds to crossfade between songs. This defaults to 0. If crossfading values is set in server side, setting this value will have no effect as server side values have higher priority.
@property (nonatomic) float secondsOfCrossfade
Declared In
AdaptrAudioPlayer.h
normalizeSongVolume
When true (the default), adjust individual song volumes so they are perceived be the same loudness.
@property (nonatomic) BOOL normalizeSongVolume
Declared In
AdaptrAudioPlayer.h
mixVolume
A value between 0.0 and 1.0 relative to system volume
@property (nonatomic) float mixVolume
Declared In
AdaptrAudioPlayer.h
Current and available stations
stationList
This is a list of streaming music stations retrieved from the server. This array will not change once populated.
@property (nonatomic, readonly, nonnull) StationArray *stationList
Declared In
AdaptrAudioPlayer.h
localOfflineStationList
The list of stations available for immediate offline playback. This list contains any stations that have been downloaded at some point in the past with downloadAndSyncStation:forTargetMinutes:withDelegate.
@property (readonly, nonatomic, nonnull) StationArray *localOfflineStationList
Return Value
List of stations available on disk ready for playback. never returns nil.
Discussion
Stations listed here are available for playback even if there is no
network connectivity, and this property is intialized as soon as the
AdaptrAudioPlayer
is created (before any attempt is made to contact
the feed.fm servers.
When there is internet connectivity, every station in this list will
have a paired station (with the same name, but not necessarily same ID)
in the remoteOfflineStationList. Use remoteOfflineStationForLocalOfflineStation:
to map to the remote Station. If they have different ‘identifier’ values,
then the local station should be updated by passing its pair to
downloadAndSyncStation:withDelegate
.
Declared In
AdaptrAudioPlayer.h
remoteOfflineStationList
List of stations that are available for downloading.
@property (readonly, nonatomic) StationArray *remoteOfflineStationList
Return Value
List of stations that can be downloaded for offline playback
Discussion
These stations cannot be tuned to (with setActiveStation:), rather they should be passed to downloadAndSyncSation:forTargetMinutes:withDelegate to be downloaded and made available for playback in the localOfflineStationList.
This property is only populated when internet connectivity is available and the player is declared ‘available’.
If one of these stations has been downloaded, the localOfflineStationForRemoteOfflineStation:
method can be used to find the local equivalent for playback.
Declared In
AdaptrAudioPlayer.h
activeStation
The current station from which music is pulled. Any Station
retrieved
from the stationList
or localOfflineStationList
properties can be assigned here.
Once music is available, this property is never null. When this value changes,
AdaptrAudioPlayerActiveStationDidChangeNotification
is sent to the default
notification center.
@property (nonatomic, copy, nonnull) Station *activeStation
Declared In
AdaptrAudioPlayer.h
– setActiveStation:withCrossfade:
Make the given station the activeStation
. If
withCrossfade
is true, any currently playing music will crossfade into the first
song in the new station.
- (void)setActiveStation:(nonnull Station *)station withCrossfade:(BOOL)withCrossfade
Parameters
station |
Station to tune to. |
---|---|
withCrossfade |
if true, if crossfading is enabled, and if music is currenty playing, the currently playing song will fade into the song in the new station as soon as it is loaded. |
See Also
Declared In
AdaptrAudioPlayer.h
Offline station management
– downloadAndSyncStation:forTargetMinutes:withDelegate:
Downloads an offline station.
- (void)downloadAndSyncStation:(nonnull Station *)remoteStation forTargetMinutes:(nullable NSNumber *)minutes withDelegate:(nonnull id<StationDownloadDelegate>)delegate
Parameters
remoteStation |
A station from remoteOfflineStationList |
---|---|
minutes |
describes target time for music. If you need music for half an hour pass 30. |
delegate |
for receiving updates about the download. |
Discussion
This method kicks off an asynchronous download to retrieve audio files for the given station. As the station downloads, events (1 at a minimum) will be sent to the provided delegate.
The station passed in must come from the remoteOfflineStationList
The minutes
attribute specifies the minimum number of minutes of
music the client would like to be available offline. The server will make the
decision as to whether the client already has enough music stored locally
and, if so, whether that music should be replaced or appended to.
Note that if the requested station has already been downloaded or partially
downloaded to local storage already, only missing music will be downloaded.
Some stations can additionally be configured (on the server) so that
only a subset of the full station contents are saved on client devices,
and each request to downloadAndSyncStation:
will cause recently played
music to be deleted and new music to be downloaded.
See Also
Declared In
AdaptrAudioPlayer.h
– downloadAndSyncStation:withDelegate:
Downloads an offline station.
- (void)downloadAndSyncStation:(nonnull Station *)remoteStation withDelegate:(nonnull id<StationDownloadDelegate>)delegate
Parameters
remoteStation |
Pass a station from remoteOfflineStationList |
---|---|
delegate |
for receiving updates about the download. |
Discussion
This method is the same as downloadAndSyncStation:forTargetMinutes:withDelegate
, but
it lets the server determine the ‘targetMinutes’ value. This method is preferable
unless the amount of music to be loaded for each station varies in different contexts
known only by the client.
See Also
Declared In
AdaptrAudioPlayer.h
– deleteOfflineStation:
Deletes all locally stored files in a previously downloaded station and
removes the station from the localOfflineStationList
.
- (void)deleteOfflineStation:(nonnull Station *)localOfflineStation
Parameters
localOfflineStation |
the station whose contents will be deleted. |
---|
Discussion
Does nothing if the station passed in does not
appear in the localOfflineStationList
or if the station being
deleted is the activeStation.
Declared In
AdaptrAudioPlayer.h
– deleteAllOfflineStations
Deletes all locally stored stations.
- (void)deleteAllOfflineStations
Discussion
This call does nothing if the current active station is a local offline station.
Declared In
AdaptrAudioPlayer.h
– localOfflineStationForRemoteOfflineStation:
Map a remote offline station to a local offline station.
- (nullable Station *)localOfflineStationForRemoteOfflineStation:(nonnull Station *)remoteOfflineStation
Parameters
remoteOfflineStation |
a station from remoteOfflineStationList |
---|
Return Value
nil or a station from remoteOfflineStationList
Discussion
This method is useful in determining which of the available remote offline stations have been downloaded and stored as local offline stations.
When a remote station is downloaded, a duplicate Station instance is added to the local offline station array. If the remote station is updated (that is, music is added or deleted), then the remote Station instance will have an ID that differs from the Station instance in the local offline station array. This station maps the remote Station instance to its local Station instance, regardless of whether their contents match up exactly.
Declared In
AdaptrAudioPlayer.h
– remoteOfflineStationForLocalOfflineStation:
Map a locally stored offline station to its remote offline pair.
- (nullable Station *)remoteOfflineStationForLocalOfflineStation:(nonnull Station *)localOfflineStation
Parameters
localOfflineStation |
a station from localOfflineStationList |
---|
Return Value
a station from remoteOfflineStationList
Discussion
This method is useful to determine if a locally downloaded station can
be updated with new music. If the local Station identifier
value
doesn’t match the remote Station identifier
value, then the remote
Station can be passed to downloadAndSyncStation:withDelegate
to update
the local Station.
Declared In
AdaptrAudioPlayer.h
Logging and reporting
logger
Any calls to logEvent:
or logEvent:withParameters:
are also sent to the logger assigned to this property, if
any.
@property (nonatomic, weak, nullable) id<AdaptrAudioPlayerLogger> logger
Declared In
AdaptrAudioPlayer.h
– logEvent:
Everything logged here goes back to Feed.fm and is also cc’d to the logger
property
- (void)logEvent:(nonnull NSString *)event
Parameters
event |
Log message |
---|
Declared In
AdaptrAudioPlayer.h
– logEvent:withParameters:
Everything logged here goes back to Feed.fm and is also cc’d to the logger
property
- (void)logEvent:(nonnull NSString *)event withParameters:(nonnull NSDictionary *)parameters
Parameters
event |
Log message |
---|---|
parameters |
Parameters |
Declared In
AdaptrAudioPlayer.h
Misc..
disableAVAudioSession
Disable the creation and management of AVAudioSession by Feed SDK completely
@property (nonatomic) BOOL disableAVAudioSession
Declared In
AdaptrAudioPlayer.h
supportedAudioFormats
Order specifies priority (earlier elements are preferred).
Nil-ing this property will allow any format to be served, but is not recommended.
Set to FMAudioFormatMP3
to exclude AAC files.
Defaults to @[FMAudioFormatAAC,FMAudioFormatMP3]
.
@property (nonatomic, strong, nullable) NSArray *supportedAudioFormats
Discussion
In the normal course of events, clients do not need to make use of this.
Declared In
AdaptrAudioPlayer.h
maxBitrate
Set to specify available bandwidth, in kbps. Set to 0 to request the highest available quality. Defaults to 48.
@property (nonatomic) NSInteger maxBitrate
Declared In
AdaptrAudioPlayer.h
statusBarNotification
This status bar notification is used to announce song changes to the user. Access the properties on this object to change how the notification is styled and to add handlers for when the notification is tapped.
@property (nonatomic, readonly, nullable) CWStatusBarNotification *statusBarNotification
Discussion
Details on this object can be found at https://github.com/cezarywojcik/CWStatusBarNotification
Declared In
AdaptrAudioPlayer.h
disableSongStartNotifications
The player displays a notification at the top of the screen during song transitions by default. If you are currently showing the active song, which means a notification isn’t needed, it can be disabled by setting this property to YES. Don’t forget to set this to NO when you stop showing the active song.
@property (nonatomic) BOOL disableSongStartNotifications
Discussion
To alter how notifications are displayed, see the statusBarNotification
property.
Declared In
AdaptrAudioPlayer.h
doesHandleRemoteCommands
If YES (the default), then the Feed.fm library will register with the MPRemoteCommandCenter to handle play/pause/skip/like/dislike commands upon start of playback.
@property (nonatomic) BOOL doesHandleRemoteCommands
Declared In
AdaptrAudioPlayer.h
lockScreenDelegate
When not NULL, this causes the AdaptrAudioPlayer to not update the MPNowPlayingInfoCenter metadata nor enable or disable the like, dislike, and next track MPFeedbackCommands. See the documentation of FMLockScreenDelegate for more information. Note that the AdaptrAudioPlayer will still register to handle the MPRemoteCommandCenter commands (play/pause/skip/like/dislike) unless doesHandleRemoteCommands is also set to NO.
@property (nonatomic, nullable) id<LockScreenDelegate> lockScreenDelegate
Declared In
AdaptrAudioPlayer.h
– setLockScreenImage:
Assigns the image to be displayed on the lock screen when music is playing.
- (void)setLockScreenImage:(nonnull UIImage *)image
Parameters
image |
The image to be added to the lock screen |
---|
Declared In
AdaptrAudioPlayer.h
+ nameForType:
Utility function to map state to string.
+ (nonnull NSString *)nameForType:(AdaptrAudioPlayerPlaybackState)type
Parameters
type |
the playback state to map to an NSString |
---|
Declared In
AdaptrAudioPlayer.h
– destroy
Destroys the instance of the player, use this call if you wish to set new tokens.
- (void)destroy
Declared In
AdaptrAudioPlayer.h
Deprecated
– getStationWithOptions:
Clients should use the StationArray
interface to
search for stations based on option values. (Deprecated: Clients should use the StationArray
interface to
search for stations based on option values.
Search throught the list of available stations, and return one that has options that match those passed in via optionKeysAndValues. This differs from getStationWithOptionKey:Value: in that you can specify multiple key/value pairs, like so:
[player getStationWithOptions: @{ @“genre”: @“80s”, @“bpm” : @“slow” }
This method returns the first station with the matching values, or nil.)
- (nullable Station *)getStationWithOptions:(nonnull NSDictionary *)optionKeysAndValues
Parameters
optionKeysAndValues |
key value pairs to search for |
---|
Return Value
a station whose options contain optionKeysAndValues
Declared In
AdaptrAudioPlayer.h
– getAllStationsWithOptions:
Clients should use the StationArray
interface to
search for stations based on option values. (Deprecated: Clients should use the StationArray
interface to
search for stations based on option values.
Similar to getStationWithOptions:, but this method returns all the stations that match the passed in optionsKeysAndValues.)
- (nullable NSArray<Station*> *)getAllStationsWithOptions:(nonnull NSDictionary *)optionKeysAndValues
Parameters
optionKeysAndValues |
key value pairs to search for |
---|
Return Value
an array of stations whose options contain optionKeysAndValues. never nil.
Declared In
AdaptrAudioPlayer.h
– setActiveStationByName:
Clients should find Station references by pulling them from stationList or localOfflineStationList and then assigning the reference to the activeStation property or calling setActiveStation:withCrossfade: (Deprecated: Clients should find Station references by pulling them from stationList or localOfflineStationList and then assigning the reference to the activeStation property or calling setActiveStation:withCrossfade:
Finds a station with the given name and assigns it to the activeStation
.)
- (BOOL)setActiveStationByName:(nonnull NSString *)name
Parameters
name |
Station name. Should not be nil. |
---|
Return Value
true if a station with the given name is found
See Also
Declared In
AdaptrAudioPlayer.h
– setActiveStationByName:withCrossfade:
Clients should find Station references by pulling them from stationList or localOfflineStationList and then assigning the reference to the activeStation property or calling setActiveStation:withCrossfade: (Deprecated: Clients should find Station references by pulling them from stationList or localOfflineStationList and then assigning the reference to the activeStation property or calling setActiveStation:withCrossfade:
Finds a station with the given name and assigns it to the activeStation
. If
withCrossfade
is true, any currently playing music will crossfade into the first
song in the new station.)
- (BOOL)setActiveStationByName:(nonnull NSString *)name withCrossfade:(BOOL)withCrossfade
Parameters
name |
Station name. Should not be nil. |
---|---|
withCrossfade |
if true, if crossfading is enabled, and if music is currenty playing, the currently playing song will fade into the song in the new station as soon as it is loaded. |
Return Value
true if a station with the given name is found
See Also
Declared In
AdaptrAudioPlayer.h
– getStationWithOptionKey:Value:
Clients should find Station references by pulling them from stationList, localOfflineStationList, or remoteOfflineStationList. (Deprecated: Clients should find Station references by pulling them from stationList, localOfflineStationList, or remoteOfflineStationList.
Search through the list of available stations, and return the one that has an option attribute named ‘key’ with a string value of ‘value’.)
- (nullable Station *)getStationWithOptionKey:(nonnull NSString *)key Value:(nonnull NSObject *)value
Parameters
key |
name of attribute to inspect |
---|---|
value |
attribute value that matching station should contain |
Declared In
AdaptrAudioPlayer.h
– prepareStations:
@deprected This method is called internally now and clients need not call it.
- (void)prepareStations:(nullable NSArray<Station*> *)stations
Parameters
stations |
list of stations to prepare |
---|
Declared In
AdaptrAudioPlayer.h
isPreparedToPlay
Clients should look for the AdaptrAudioPlayerMusicQueuedNotification notification to know when music is queued up in the player, rather than rely on this property, which will be removed in the next major version. (Deprecated: Clients should look for the AdaptrAudioPlayerMusicQueuedNotification notification to know when music is queued up in the player, rather than rely on this property, which will be removed in the next major version.
Indicates if the SDK has retrieved the next song for playback from the server and is ready to start playing it.)
@property (nonatomic, readonly) BOOL isPreparedToPlay
Declared In
AdaptrAudioPlayer.h
+ setClientToken:secret:detectLocalMusic:
local detection is no longer performed by this library (Deprecated: local detection is no longer performed by this library
This call to initialize the library and then detect whether the user had any local music available for playback.)
+ (void)setClientToken:(nonnull NSString *)token secret:(nonnull NSString *)secret detectLocalMusic:(BOOL)detectLocalMusic
Parameters
token |
public authentication token. Use |
---|---|
secret |
private authentication token. Use |
detectLocalMusic |
when true, the user’s local media collection will be queried to sample what type of music they listen to |
Declared In
AdaptrAudioPlayer.h
– seekStationBy:
Seek station by give no of seconds. Max allowed value can be obtained by maxSeekableLength
- (void)seekStationBy:(NSTimeInterval)time
Parameters
time |
in seconds |
---|
See Also
Declared In
AdaptrAudioPlayer.h
– maxSeekableLength
Max no of seconds that can be seeked in the current station
- (NSTimeInterval)maxSeekableLength
Return Value
Time in seconds
Declared In
AdaptrAudioPlayer.h
– setAVAudioSessionCategory:mode:options:
This method sets the default configuration values when the AdaptrAudioPlayer initializes an AVAudioSession.
- (void)setAVAudioSessionCategory:(nonnull AVAudioSessionCategory)category mode:(nonnull AVAudioSessionMode)mode options:(AVAudioSessionCategoryOptions)options
Parameters
category |
category to request when player gets AVAudioSession |
---|---|
mode |
mode to request when player gets AVAudioSession |
options |
category options to set when player gets AVAudioSession |
Discussion
When playback starts, the AdaptrAudioPlayer needs to ensure there is an active AVAudioSession. By default, the player sets the AVAudioSessionCategory to AVAudioSessionCategoryPlayback, the mode to AVAudioSessionModeDefault, and the options to AVAudioSessionCategoryOptionMixWithOthers. If you would like the player to use alternate settings, assign them here before playback begins.
(note: this method does not immediately call AVAudioSession setCategory:mode:options:error - it only assigns the default values that the player will use when it needs to get an AVAudioSession)
Declared In
AdaptrAudioPlayer.h
– submitLogsForRemoteDebuggingWithLabel:
This method sends all Feed SDK generated logs since the start of the application to feed.fm for manual debugging. If you are experiencing unexpected behavior with the SDK, call this method after the bad behavior occurs and let your customer support person at feed know what value you passed for ‘label’.
- (void)submitLogsForRemoteDebuggingWithLabel:(nonnull NSString *)label
Parameters
label |
a unique label to assist feed.fm engineers in finding this specific log |
---|
Declared In
AdaptrAudioPlayer.h