StationCrossfader Class Reference
Inherits from | NSObject |
---|---|
Declared in | StationCrossfader.h |
Overview
The StationCrossfader allows you to tie music player actions (such as station changes and volume changes) to cue points. The basic use case is to change stations and volume while playing instructional audio in a separate audio player.
Basic class usage works like so: Create an instance of the class with an array of time offsets (cue points) and the actions you want to happen at those times. The current implementation allows you to change the current station or volume. You can create an instance like so:
StationCrossfader *cf = [StationCrossfade stationCrossfaderWithInitialStation:@{ @“bpm”: @“slow” }, andCuePoints: @[ // at 5 seconds in, change the volume to 0.5 5.0f, @0.5f, // also at 5 seconds in, crosfade to the station // with a ‘bpm’ value of ‘medium’ 5.0f, @{ @“bpm”: @“medium” }, // at 10 seconds in, change volume to 1.0 10.0f, @1.0f, // and crossfade to station with ‘bpm’ of ‘high’ 10.0f, @{ @“bpm”: @“high” } ]];
Alternatively, you can create an instance of the class with no cue points and then use playStation:startingAtTime: and setVolume:startingAtTime to add cue points.
When you have added all the cue points, make a call to:
[cf connect];
Now, as your external media elapses, inform the station crossfader:
[cf elapseToTime: _externalMediaPlayer.currentElapsedTime]
which call will cause the crossfader to update the current station and volume settings as per the cue points.
When any external media that the cue points are connected to starts playback
or pauses playback, you should call [cf play]
or [cf pause]
.
If the user pauses playback of music (independent of your external media), then call [cf disconnect] so that music stays paused until the user turns it back on again. When the user wants to resume playback, call [cf reconnect].