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 -
urlproperty -
strictContentTypeCheckingproperty -
outputFileproperty -
defaultContentTypeproperty -
contentTypeproperty -
suggestedFileExtensionproperty -
defaultContentLengthproperty -
contentLengthproperty -
audioDataByteCountproperty -
currentTimePlayedproperty -
durationproperty -
currentSeekByteOffsetproperty -
bitRateproperty -
continuousproperty -
cachedproperty -
prebufferedByteCountproperty -
volumeproperty -
totalCachedObjectsSizeproperty -
retryCountproperty -
maxRetryCountproperty -
levelsproperty -
statisticsproperty -
onCompletionproperty -
onStateChangeproperty -
onMetaDataAvailableproperty -
onFailureproperty -
configurationproperty -
delegateproperty
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 audioDataByteCountDiscussion
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.hbitRate
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 bitRateDiscussion
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.hcached
The property is true if the stream has been cached locally.
@property (nonatomic, readonly) BOOL cachedDiscussion
The property is true if the stream has been cached locally.
Declared In
FSAudioStream.hconfiguration
The property has the low-level stream configuration.
@property (readonly) FSStreamConfiguration *configurationDiscussion
The property has the low-level stream configuration.
Declared In
FSAudioStream.hcontentLength
The property has the content length of the stream (in bytes). The length is zero if the stream is continuous.
@property (nonatomic, readonly) UInt64 contentLengthDiscussion
The property has the content length of the stream (in bytes). The length is zero if the stream is continuous.
Declared In
FSAudioStream.hcontentType
The property has the content type of the stream, for instance audio/mpeg.
@property (nonatomic, readonly) NSString *contentTypeDiscussion
The property has the content type of the stream, for instance audio/mpeg.
Declared In
FSAudioStream.hcontinuous
The property is true if the stream is continuous (no known duration).
@property (nonatomic, readonly) BOOL continuousDiscussion
The property is true if the stream is continuous (no known duration).
Declared In
FSAudioStream.hcurrentSeekByteOffset
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 currentSeekByteOffsetDiscussion
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.hcurrentTimePlayed
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 currentTimePlayedDiscussion
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.hdefaultContentLength
Sets a default content length for the stream. Used if the stream content-length is not available.
@property (nonatomic, assign) UInt64 defaultContentLengthDiscussion
Sets a default content length for the stream. Used if the stream content-length is not available.
Declared In
FSAudioStream.hdefaultContentType
Sets a default content type for the stream. Used if the stream content type is not available.
@property (nonatomic, assign) NSString *defaultContentTypeDiscussion
Sets a default content type for the stream. Used if the stream content type is not available.
Declared In
FSAudioStream.hdelegate
Delegate.
@property (nonatomic, unsafe_unretained) IBOutlet id<FSPCMAudioStreamDelegate> delegateDiscussion
Delegate.
Declared In
FSAudioStream.hduration
This property has the duration of the stream, if the stream is noncontinuous. Continuous streams do not have a duration.
@property (nonatomic, readonly) FSStreamPosition durationDiscussion
This property has the duration of the stream, if the stream is noncontinuous. Continuous streams do not have a duration.
Declared In
FSAudioStream.hlevels
The property determines the current audio levels.
@property (nonatomic, readonly) FSLevelMeterState levelsDiscussion
The property determines the current audio levels.
Declared In
FSAudioStream.hmaxRetryCount
Holds the maximum amount of playback retries that will be performed before entering kFsAudioStreamRetryingFailed state. Default is 3.
@property (nonatomic, assign) NSUInteger maxRetryCountDiscussion
Holds the maximum amount of playback retries that will be performed before entering kFsAudioStreamRetryingFailed state. Default is 3.
Declared In
FSAudioStream.honCompletion
Called upon completion of the stream. Note that for continuous streams this is never called.
@property (copy) void ( ^ ) ( ) onCompletionDiscussion
Called upon completion of the stream. Note that for continuous streams this is never called.
Declared In
FSAudioStream.honFailure
Called upon a failure.
@property (copy) void ( ^ ) ( FSAudioStreamError error , NSString *errorDescription ) onFailureDiscussion
Called upon a failure.
Declared In
FSAudioStream.honMetaDataAvailable
Called upon a meta data is available.
@property (copy) void ( ^ ) ( NSDictionary *metadata ) onMetaDataAvailableDiscussion
Called upon a meta data is available.
Declared In
FSAudioStream.honStateChange
Called upon a state change.
@property (copy) void ( ^ ) ( FSAudioStreamState state ) onStateChangeDiscussion
Called upon a state change.
Declared In
FSAudioStream.houtputFile
Set an output file to store the stream contents to a file.
@property (nonatomic, assign) NSURL *outputFileDiscussion
Set an output file to store the stream contents to a file.
Declared In
FSAudioStream.hprebufferedByteCount
This property has the number of bytes buffered for this stream.
@property (nonatomic, readonly) size_t prebufferedByteCountDiscussion
This property has the number of bytes buffered for this stream.
Declared In
FSAudioStream.hretryCount
The property determines the amount of times the stream has tried to retry the playback in case of failure.
@property (nonatomic, readonly) NSUInteger retryCountDiscussion
The property determines the amount of times the stream has tried to retry the playback in case of failure.
Declared In
FSAudioStream.hstatistics
This property holds the current statistics for the stream state.
@property (nonatomic, readonly) FSStreamStatistics *statisticsDiscussion
This property holds the current statistics for the stream state.
Declared In
FSAudioStream.hstrictContentTypeChecking
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 strictContentTypeCheckingDiscussion
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.hsuggestedFileExtension
The property has the suggested file extension for the stream based on the stream content type.
@property (nonatomic, readonly) NSString *suggestedFileExtensionDiscussion
The property has the suggested file extension for the stream based on the stream content type.
Declared In
FSAudioStream.htotalCachedObjectsSize
The current size of the disk cache.
@property (nonatomic, readonly) unsigned long long totalCachedObjectsSizeDiscussion
The current size of the disk cache.
Declared In
FSAudioStream.hurl
The stream URL.
@property (nonatomic, assign) NSURL *urlDiscussion
The stream URL.
Declared In
FSAudioStream.hvolume
This property holds the current playback volume of the stream, from 0.0 to 1.0.
@property (nonatomic, assign) float volumeDiscussion
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.hInstance Methods
expungeCache
Cleans all cached data from the persistent storage.
- (void)expungeCacheDiscussion
Cleans all cached data from the persistent storage.
Declared In
FSAudioStream.hinitWithConfiguration:
Initializes the stream with a configuration.
- (id)initWithConfiguration:(FSStreamConfiguration *)configurationParameters
- configuration
The stream configuration.
Discussion
Initializes the stream with a configuration.
Declared In
FSAudioStream.hinitWithUrl:
Initializes the audio stream with an URL.
- (id)initWithUrl:(NSURL *)urlParameters
- url
The URL from which the stream data is retrieved.
Discussion
Initializes the audio stream with an URL.
Declared In
FSAudioStream.hisPlaying
Returns the playback status: YES if the stream is playing, NO otherwise.
- (BOOL)isPlayingDiscussion
Returns the playback status: YES if the stream is playing, NO otherwise.
Declared In
FSAudioStream.hpause
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)pauseDiscussion
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.hplay
Starts playing the stream. If no playback URL is defined, an error will occur.
- (void)playDiscussion
Starts playing the stream. If no playback URL is defined, an error will occur.
Declared In
FSAudioStream.hplayFromOffset:
Starts playing the stream from the given offset. The offset can be retrieved from the stream with the currentSeekByteOffset property.
- (void)playFromOffset:(FSSeekByteOffset)offsetParameters
- 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.hplayFromURL:
Starts playing the stream from the given URL.
- (void)playFromURL:(NSURL *)urlParameters
- url
The URL from which the stream data is retrieved.
Discussion
Starts playing the stream from the given URL.
Declared In
FSAudioStream.hpreload
Starts preload the stream. If no preload URL is defined, an error will occur.
- (void)preloadDiscussion
Starts preload the stream. If no preload URL is defined, an error will occur.
Declared In
FSAudioStream.hrewind:
Rewinds the stream. Only possible for continuous streams.
- (void)rewind:(unsigned)secondsParameters
- seconds
Seconds to rewind the stream.
Discussion
Rewinds the stream. Only possible for continuous streams.
Declared In
FSAudioStream.hseekToPosition:
Seeks the stream to a given position. Requires a noncontinuous stream (a stream with a known duration).
- (void)seekToPosition:(FSStreamPosition)positionParameters
- 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.hsetPlayRate:
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)playRateParameters
- 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