WOWZPlayer

Superclass:
NSObject
Declared In:

Introduction

Use the WOWZPlayer class to play streams from Wowza Streaming Engine or Wowza Streaming Cloud over the WOWZ protocol, as well as to play ultra low latency streams from Wowza Streaming Cloud. WOWZPlayer decompresses audio and video, plays audio through the device speaker, and displays video frames in a UIView.



Methods

-currentPlaybackErrorCount
-currentPlayState
-pauseHLSPlayback
-play:callback:
-registerDataSink:eventName:
-resetPlaybackErrorCount
-setupHLSWithView:
-startHLSPlayback
-stop
-stopHLSPlayback
-unregisterDataSink:eventName:
-updateMaxLatencyInSecondsForAudio:
-updateViewLayouts

currentPlaybackErrorCount


-(NSUInteger) currentPlaybackErrorCount; 
Discussion

Gets the current playback error count - used for HLS fallback (2 errors is default then fallback).


currentPlayState


-(WOWZState) currentPlayState; 
Discussion

Get the current playing state of the WOWZPlayer instance.


pauseHLSPlayback


-(void) pauseHLSPlayback; 
Discussion

Pauses the HLS fallback stream. Note that Apple's AVPlayer is used to play HLS fallback streams. To handle certain playback events, such as unexpected stoppages, use AVPlayer and custom notifications.


play:callback:


-(void) play:(nonnull WowzaConfig *)config callback:(nullable id<WOWZStatusCallback>)statusCallback; 
Parameters
config

The WowzaConfig that specifes the host, port, app name, and stream name to play.

statusCallback

The callback to be invoked with playback session status updates and errors.

Discussion

Starts playing the stream.


registerDataSink:eventName:


-(void) registerDataSink:(nonnull id<WOWZDataSink>)sink 
        eventName:(nonnull NSString *)eventName; 
Parameters
sink

An object that conforms to the WOWZAudioEncoderSink protocol.

eventName

The name of the data event that the client should listen for.

Discussion

Registers a WOWZDataSink object with WOWZPlayer. WOWZDataSink protocol methods are called when the player is active and a data event is received from the server.


resetPlaybackErrorCount


-(void) resetPlaybackErrorCount; 
Discussion

Resets the playback error count to zero.


setupHLSWithView:


-(void)setupHLSWithView:(UIView *_Nullable)viewToAttachTo; 
Discussion

Sets up the HLS fallback stream. Can be used with ultra low latency streams from Wowza Streaming Cloud; note, however, that Apple HLS streams experience greater latency than WebSocket streams.


startHLSPlayback


-(void) startHLSPlayback; 
Discussion

Starts playing the HLS fallback stream. Note that Apple's AVPlayer is used to play HLS fallback streams. To handle certain playback events, such as unexpected stoppages, use AVPlayer and custom notifications.


stop


-(void) stop; 
Discussion

Sets the current playing state of the WOWZPlayer instance to WOWZStateStopping and then stops playing the stream. This method is locked using @synchronized(self). After playback is stopped, the current playing state is WOWZStateStopping.


stopHLSPlayback


-(void) stopHLSPlayback; 
Discussion

Stops playing the HLS fallback stream. Note that Apple's AVPlayer is used to play HLS fallback streams. To handle certain playback events, such as unexpected stoppages, use AVPlayer and custom notifications.


unregisterDataSink:eventName:


-(void) unregisterDataSink:(nonnull id<WOWZDataSink>)sink 
        eventName:(nonnull NSString *)eventName; 
Parameters
sink

An object that conforms to the WOWZDataSink protocol.

Discussion

Unregisters a WOWZDataSink object from WOWZPlayer.


updateMaxLatencyInSecondsForAudio:


-(void) updateMaxLatencyInSecondsForAudio:(UInt32)numberOfSeconds; 
Discussion

Sets in a range from 1 - 4 the number of seconds of latency that the audio buffer will allow until it dumps and resets on most recent incoming audio frames. It is recommended to leave this at the defaul of 3 as having some flexible time for samplerate cross conversion is good or else you may hear glitches in audio when the buffer is flushed because of max headroom reached.


updateViewLayouts


-(void) updateViewLayouts; 

Typedefs

NS_ENUM
WOWZPlayerViewGravityResizeAspect

NS_ENUM


typedef NS_ENUM(NSUInteger, WOWZPlayerViewGravity) { 
    WOWZPlayerViewGravityResizeAspect = 0, WOWZPlayerViewGravityResizeAspectFill 
}; 
Constants
WOWZPlayerViewGravityResizeAspect

Preserve the video's aspect ratio and fit it within layer bounds.

WOWZPlayerViewGravityResizeAspectFill

Preserve the video's aspect ratio and fill layer bounds.

Discussion

Describes how the video is displayed in the player's available screen area.

See Also


WOWZPlayerViewGravityResizeAspect


typedef NS_ENUM(NSUInteger, WOWZPlayerViewGravity) { 
    WOWZPlayerViewGravityResizeAspect = 0, WOWZPlayerViewGravityResizeAspectFill 
}; 
Constants
WOWZPlayerViewGravityResizeAspect

Preserve the video's aspect ratio and fit it within layer bounds.

WOWZPlayerViewGravityResizeAspectFill

Preserve the video's aspect ratio and fill layer bounds.

Discussion

Describes how the video is displayed in the player's available screen area.

See Also


Properties

captureLastRenderedFrame
clientCallback
currentInjestBitrate
currentTime
hlsPlayer
hlsPlayerItem
hlsVideoPlayerLayer
metaData
muted
playerView
playerViewGravity
prerollDuration
shouldHandleBackgroundNotificationAndStopPlayer
syncOffset
useHLSFallback
volume

captureLastRenderedFrame


@property (nonatomic,
    assign) BOOL captureLastRenderedFrame; 

clientCallback


@property (nonatomic,
    weak) NSObject<WOWZStatusCallback> * _Nullable clientCallback; 
Discussion

Access to the client callback incase the order of deinit/dealloc needs to be manually controlled on the delegate callback.


currentInjestBitrate


@property (nonatomic,
    assign) Float32 currentInjestBitrate; 
Discussion

The incoming bitrate during playback this is a combination of time of play calculated against length of total buffers incoming.


currentTime


@property (nonatomic,
    readonly) CMTime currentTime; 
Discussion

The timecode of the most recent frame displayed by the player, relative to the starting timecode. Returns kCMTimeInvalid if a stream isn't playing or if the player hasn't received any frames.


hlsPlayer


@property (nonatomic,
    strong) AVPlayer * _Nullable hlsPlayer; 
Discussion

The hls AVPlayer from Apple.


hlsPlayerItem


@property (nonatomic,
    strong) AVPlayerItem * _Nullable hlsPlayerItem; 
Discussion

The hlsPlayerItem.


hlsVideoPlayerLayer


@property (nonatomic,
    strong) AVPlayerLayer * _Nullable hlsVideoPlayerLayer; 
Discussion

The hls AVPlayerLayer from Apple.


metaData


@property (nonatomic,
    readonly,
    nullable) WOWZDataMap *metaData; 
Discussion

The stream metadata for the stream that's playing.


muted


@property (nonatomic,
    assign) BOOL muted; 
Discussion

Mute or unmute the audio. The default is no, or unmuted.


playerView


@property (nonatomic,
    weak) UIView * _Nullable playerView; 
Discussion

The UIView to which the player should be added.


playerViewGravity


@property (nonatomic,
    assign) WOWZPlayerViewGravity playerViewGravity; 
Discussion

The gravity to use to display the video in the host view. Gravity describes how the video frame fills the available screen area.


prerollDuration


@property (nonatomic,
    assign) Float64 prerollDuration; 
Discussion

The amount of time to buffer the video before playing. The default is 0 seconds; the maximum is 60 seconds.


shouldHandleBackgroundNotificationAndStopPlayer


@property (nonatomic,
    assign) BOOL shouldHandleBackgroundNotificationAndStopPlayer; 
Discussion

A Boolean value that determines whether WOWZPlayer handles UIApplicationDidEnterBackgroundNotification notifications. The default value is YES. If set to YES, WOWZPlayer handles the notification and in response automatically stops the playback stream. If set to NO, WOWZPlayer does not handle UIApplicationDidEnterBackgroundNotification notifications. This lets the developer control stoppage of the playback stream in another way. IMPORTANT: If the value is set to NO and the developer does not control stoppage of the playback stream in another way, the playing state is likely to enter an undesirable condition at some point.


syncOffset


@property (nonatomic,
    assign) Float32 syncOffset; 
Discussion

The sync offset to scrub video to sync. Specify a value between -1.0 and 3.0 seconds; any value outside of this range will be ignored. The default is 1.0.


useHLSFallback


@property (nonatomic,
    assign) BOOL useHLSFallback; 
Discussion

Play an Apple HLS stream as a fallback if the primary WOWZ-based conection is unsuccessful. Can be used with ultra low latency streams from Wowza Streaming Cloud; note, however, that Apple HLS streams experience greater latency than WebSocket streams.


volume


@property (nonatomic,
    assign) Float32 volume; 
Discussion

The volume to play the audio. Specify a value between 0.0 (silent) and 1.0 (full volume); any value outside of this range will be ignored. The default is 1.0.