FSAudioStream Class Reference
Inherits from | NSObject |
Declared in | FSAudioStream.h |
Overview
FSAudioStream is a class for streaming audio files from an URL. It must be directly fed with an URL, which contains audio. That is, playlists or other non-audio formats yield an error.
To start playback, the stream must be either initialized with an URL or the playback URL can be set with the url property. The playback is started with the play method. It is possible to pause or stop the stream with the respective methods.
Noncontinuous streams (audio streams with a known duration) can be seeked with the seekToPosition method.
Note that FSAudioStream is not designed to be thread-safe! That means that using the streamer from multiple threads without syncronization could cause problems. It is recommended to keep the streamer in the main thread and call the streamer methods only from the main thread (consider using performSelectorOnMainThread: if calls from multiple threads are needed).
Tasks
-
– initWithUrl:
-
– initWithConfiguration:
-
– preload
-
– play
-
– playFromURL:
-
– playFromOffset:
-
– stop
-
– pause
-
– rewind:
-
– seekToPosition:
-
– setPlayRate:
-
– isPlaying
-
– expungeCache
-
url
property -
strictContentTypeChecking
property -
outputFile
property -
defaultContentType
property -
contentType
property -
suggestedFileExtension
property -
defaultContentLength
property -
contentLength
property -
audioDataByteCount
property -
currentTimePlayed
property -
duration
property -
currentSeekByteOffset
property -
bitRate
property -
continuous
property -
cached
property -
prebufferedByteCount
property -
volume
property -
totalCachedObjectsSize
property -
retryCount
property -
maxRetryCount
property -
levels
property -
statistics
property -
onCompletion
property -
onStateChange
property -
onMetaDataAvailable
property -
onFailure
property -
configuration
property -
delegate
property
Properties
audioDataByteCount
The number of bytes of audio data. Notice that this may differ from the number of bytes the server returns for the content length! For instance audio file meta data is excluded from the count. Effectively you can use this property for seeking calculations.
@property (nonatomic, readonly) UInt64 audioDataByteCount
Discussion
The number of bytes of audio data. Notice that this may differ from the number of bytes the server returns for the content length! For instance audio file meta data is excluded from the count. Effectively you can use this property for seeking calculations.
Declared In
FSAudioStream.h
bitRate
This property has the bit rate of the stream. The bit rate is initially 0, before the stream has processed enough packets to calculate the bit rate.
@property (nonatomic, readonly) float bitRate
Discussion
This property has the bit rate of the stream. The bit rate is initially 0, before the stream has processed enough packets to calculate the bit rate.
Declared In
FSAudioStream.h
cached
The property is true if the stream has been cached locally.
@property (nonatomic, readonly) BOOL cached
Discussion
The property is true if the stream has been cached locally.
Declared In
FSAudioStream.h
configuration
The property has the low-level stream configuration.
@property (readonly) FSStreamConfiguration *configuration
Discussion
The property has the low-level stream configuration.
Declared In
FSAudioStream.h
contentLength
The property has the content length of the stream (in bytes). The length is zero if the stream is continuous.
@property (nonatomic, readonly) UInt64 contentLength
Discussion
The property has the content length of the stream (in bytes). The length is zero if the stream is continuous.
Declared In
FSAudioStream.h
contentType
The property has the content type of the stream, for instance audio/mpeg.
@property (nonatomic, readonly) NSString *contentType
Discussion
The property has the content type of the stream, for instance audio/mpeg.
Declared In
FSAudioStream.h
continuous
The property is true if the stream is continuous (no known duration).
@property (nonatomic, readonly) BOOL continuous
Discussion
The property is true if the stream is continuous (no known duration).
Declared In
FSAudioStream.h
currentSeekByteOffset
This property has the current seek byte offset of the stream, if the stream is noncontinuous. Continuous streams do not have a seek byte offset.
@property (nonatomic, readonly) FSSeekByteOffset currentSeekByteOffset
Discussion
This property has the current seek byte offset of the stream, if the stream is noncontinuous. Continuous streams do not have a seek byte offset.
Declared In
FSAudioStream.h
currentTimePlayed
This property has the current playback position, if the stream is noncontinuous. The current playback position cannot be determined for continuous streams.
@property (nonatomic, readonly) FSStreamPosition currentTimePlayed
Discussion
This property has the current playback position, if the stream is noncontinuous. The current playback position cannot be determined for continuous streams.
Declared In
FSAudioStream.h
defaultContentLength
Sets a default content length for the stream. Used if the stream content-length is not available.
@property (nonatomic, assign) UInt64 defaultContentLength
Discussion
Sets a default content length for the stream. Used if the stream content-length is not available.
Declared In
FSAudioStream.h
defaultContentType
Sets a default content type for the stream. Used if the stream content type is not available.
@property (nonatomic, assign) NSString *defaultContentType
Discussion
Sets a default content type for the stream. Used if the stream content type is not available.
Declared In
FSAudioStream.h
delegate
Delegate.
@property (nonatomic, unsafe_unretained) IBOutlet id<FSPCMAudioStreamDelegate> delegate
Discussion
Delegate.
Declared In
FSAudioStream.h
duration
This property has the duration of the stream, if the stream is noncontinuous. Continuous streams do not have a duration.
@property (nonatomic, readonly) FSStreamPosition duration
Discussion
This property has the duration of the stream, if the stream is noncontinuous. Continuous streams do not have a duration.
Declared In
FSAudioStream.h
levels
The property determines the current audio levels.
@property (nonatomic, readonly) FSLevelMeterState levels
Discussion
The property determines the current audio levels.
Declared In
FSAudioStream.h
maxRetryCount
Holds the maximum amount of playback retries that will be performed before entering kFsAudioStreamRetryingFailed state. Default is 3.
@property (nonatomic, assign) NSUInteger maxRetryCount
Discussion
Holds the maximum amount of playback retries that will be performed before entering kFsAudioStreamRetryingFailed state. Default is 3.
Declared In
FSAudioStream.h
onCompletion
Called upon completion of the stream. Note that for continuous streams this is never called.
@property (copy) void ( ^ ) ( ) onCompletion
Discussion
Called upon completion of the stream. Note that for continuous streams this is never called.
Declared In
FSAudioStream.h
onFailure
Called upon a failure.
@property (copy) void ( ^ ) ( FSAudioStreamError error , NSString *errorDescription ) onFailure
Discussion
Called upon a failure.
Declared In
FSAudioStream.h
onMetaDataAvailable
Called upon a meta data is available.
@property (copy) void ( ^ ) ( NSDictionary *metadata ) onMetaDataAvailable
Discussion
Called upon a meta data is available.
Declared In
FSAudioStream.h
onStateChange
Called upon a state change.
@property (copy) void ( ^ ) ( FSAudioStreamState state ) onStateChange
Discussion
Called upon a state change.
Declared In
FSAudioStream.h
outputFile
Set an output file to store the stream contents to a file.
@property (nonatomic, assign) NSURL *outputFile
Discussion
Set an output file to store the stream contents to a file.
Declared In
FSAudioStream.h
prebufferedByteCount
This property has the number of bytes buffered for this stream.
@property (nonatomic, readonly) size_t prebufferedByteCount
Discussion
This property has the number of bytes buffered for this stream.
Declared In
FSAudioStream.h
retryCount
The property determines the amount of times the stream has tried to retry the playback in case of failure.
@property (nonatomic, readonly) NSUInteger retryCount
Discussion
The property determines the amount of times the stream has tried to retry the playback in case of failure.
Declared In
FSAudioStream.h
statistics
This property holds the current statistics for the stream state.
@property (nonatomic, readonly) FSStreamStatistics *statistics
Discussion
This property holds the current statistics for the stream state.
Declared In
FSAudioStream.h
strictContentTypeChecking
Determines if strict content type checking is required. If the audio stream cannot determine that the stream is actually an audio stream, the stream does not play. Disabling strict content type checking bypasses the stream content type checks and tries to play the stream regardless of the content type information given by the server.
@property (nonatomic, assign) BOOL strictContentTypeChecking
Discussion
Determines if strict content type checking is required. If the audio stream cannot determine that the stream is actually an audio stream, the stream does not play. Disabling strict content type checking bypasses the stream content type checks and tries to play the stream regardless of the content type information given by the server.
Declared In
FSAudioStream.h
suggestedFileExtension
The property has the suggested file extension for the stream based on the stream content type.
@property (nonatomic, readonly) NSString *suggestedFileExtension
Discussion
The property has the suggested file extension for the stream based on the stream content type.
Declared In
FSAudioStream.h
totalCachedObjectsSize
The current size of the disk cache.
@property (nonatomic, readonly) unsigned long long totalCachedObjectsSize
Discussion
The current size of the disk cache.
Declared In
FSAudioStream.h
url
The stream URL.
@property (nonatomic, assign) NSURL *url
Discussion
The stream URL.
Declared In
FSAudioStream.h
volume
This property holds the current playback volume of the stream, from 0.0 to 1.0.
@property (nonatomic, assign) float volume
Discussion
This property holds the current playback volume of the stream, from 0.0 to 1.0.
Note that the overall volume is still constrained by the volume set by the user! So the actual volume cannot be higher than the volume currently set by the user. For example, if requesting a volume of 0.5, then the volume will be 50% lower than the current playback volume set by the user.
Declared In
FSAudioStream.h
Instance Methods
expungeCache
Cleans all cached data from the persistent storage.
- (void)expungeCache
Discussion
Cleans all cached data from the persistent storage.
Declared In
FSAudioStream.h
initWithConfiguration:
Initializes the stream with a configuration.
- (id)initWithConfiguration:(FSStreamConfiguration *)configuration
Parameters
- configuration
The stream configuration.
Discussion
Initializes the stream with a configuration.
Declared In
FSAudioStream.h
initWithUrl:
Initializes the audio stream with an URL.
- (id)initWithUrl:(NSURL *)url
Parameters
- url
The URL from which the stream data is retrieved.
Discussion
Initializes the audio stream with an URL.
Declared In
FSAudioStream.h
isPlaying
Returns the playback status: YES if the stream is playing, NO otherwise.
- (BOOL)isPlaying
Discussion
Returns the playback status: YES if the stream is playing, NO otherwise.
Declared In
FSAudioStream.h
pause
If the stream is playing, the stream playback is paused upon calling pause. Otherwise (the stream is paused), calling pause will continue the playback.
- (void)pause
Discussion
If the stream is playing, the stream playback is paused upon calling pause. Otherwise (the stream is paused), calling pause will continue the playback.
Declared In
FSAudioStream.h
play
Starts playing the stream. If no playback URL is defined, an error will occur.
- (void)play
Discussion
Starts playing the stream. If no playback URL is defined, an error will occur.
Declared In
FSAudioStream.h
playFromOffset:
Starts playing the stream from the given offset. The offset can be retrieved from the stream with the currentSeekByteOffset property.
- (void)playFromOffset:(FSSeekByteOffset)offset
Parameters
- offset
The offset where to start playback from.
Discussion
Starts playing the stream from the given offset. The offset can be retrieved from the stream with the currentSeekByteOffset property.
Declared In
FSAudioStream.h
playFromURL:
Starts playing the stream from the given URL.
- (void)playFromURL:(NSURL *)url
Parameters
- url
The URL from which the stream data is retrieved.
Discussion
Starts playing the stream from the given URL.
Declared In
FSAudioStream.h
preload
Starts preload the stream. If no preload URL is defined, an error will occur.
- (void)preload
Discussion
Starts preload the stream. If no preload URL is defined, an error will occur.
Declared In
FSAudioStream.h
rewind:
Rewinds the stream. Only possible for continuous streams.
- (void)rewind:(unsigned)seconds
Parameters
- seconds
Seconds to rewind the stream.
Discussion
Rewinds the stream. Only possible for continuous streams.
Declared In
FSAudioStream.h
seekToPosition:
Seeks the stream to a given position. Requires a noncontinuous stream (a stream with a known duration).
- (void)seekToPosition:(FSStreamPosition)position
Parameters
- position
The stream position to seek to.
Discussion
Seeks the stream to a given position. Requires a noncontinuous stream (a stream with a known duration).
Declared In
FSAudioStream.h
setPlayRate:
Sets the audio stream playback rate from 0.5 to 2.0. Value 1.0 means the normal playback rate. Values below 1.0 means a slower playback rate than usual and above 1.0 a faster playback rate. Notice that using a faster playback rate than 1.0 may mean that you have to increase the buffer sizes for the stream still to play.
- (void)setPlayRate:(float)playRate
Parameters
- playRate
The playback rate.
Discussion
Sets the audio stream playback rate from 0.5 to 2.0. Value 1.0 means the normal playback rate. Values below 1.0 means a slower playback rate than usual and above 1.0 a faster playback rate. Notice that using a faster playback rate than 1.0 may mean that you have to increase the buffer sizes for the stream still to play.
The play rate has only effect if the stream is playing.
Declared In
FSAudioStream.h