STSSDKPlayerView

@interface STSSDKPlayerView : UIView

An instance of STSSDKPlayerView is a means for loading media to play and control playback.

  • The receiver’s delegate.

    Declaration

    Objective-C

    @property (nonatomic, weak, readwrite, nullable)
        id<STSSDKPlayerViewDelegate, STSPlayerPlaybackEventDelegate>
            delegate;

    Swift

    weak var delegate: (STSPlayerPlaybackEventDelegate & STSSDKPlayerViewDelegate)? { get set }
  • The object that acts as the playlist event delegate of the player view. Set nil if it has no playlist event delegate.

    Declaration

    Objective-C

    @property (nonatomic, weak, readwrite, nullable)
        id<STSPlayerPlaylistEventDelegate>
            playlistEventDelegate;

    Swift

    weak var playlistEventDelegate: STSPlayerPlaylistEventDelegate? { get set }
  • The object that acts as the live event delegate of the player view. Set nil if it has no live event delegate.

    Declaration

    Objective-C

    @property (nonatomic, weak, readwrite, nullable) id<STSPlayerLiveEventDelegate>
        liveEventDelegate;

    Swift

    weak var liveEventDelegate: STSPlayerLiveEventDelegate? { get set }
  • The view that contains playback controls and infos.

    Declaration

    Objective-C

    @property (nonatomic, readonly)
        STSSDKPlayerControlView *_Nonnull playerControlView;

    Swift

    var playerControlView: STSSDKPlayerControlView { get }
  • The image that will show in the control center. If this property is nil, the player view will use the thumbnail of the media (live or VOD) as the control center image.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite, nullable)
        UIImage *imageForControlCenter;

    Swift

    var imageForControlCenter: UnsafeMutablePointer<Int32>? { get set }
  • A boolean value indicates whether the player view is able to display the player control when necessary.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL canShowPlayerControlView;

    Swift

    var canShowPlayerControlView: Bool { get set }
  • A boolean value indicates whether the player view is able to display the default error view when error occurs.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL canShowErrorView;

    Swift

    var canShowErrorView: Bool { get set }
  • A boolean value indicates whether the player view is able to display the default loading indicator on loading.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL canShowLoadingIndicator;

    Swift

    var canShowLoadingIndicator: Bool { get set }
  • A boolean value indicates whether the player view can display the default broadcast state message when the player is playing a live. Defaults to YES.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL canShowBroadcastStateMessage;

    Swift

    var canShowBroadcastStateMessage: Bool { get set }
  • A boolean value indicates whether the player can keep playing in background. Defaults to NO.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL allowsPlayingInBackground;

    Swift

    var allowsPlayingInBackground: Bool { get set }
  • A boolean value indicates whether the player should respond to the remote control events while playing a media. Defaults to NO.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL remoteControlEnabled;

    Swift

    var remoteControlEnabled: Bool { get set }
  • A boolean value indicates whether the player should show caption. Defaults to NO. It will be change to YES after the caption exists and the caption is successfully downloaded.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite) BOOL captionEnabled;

    Swift

    var captionEnabled: Bool { get set }
  • The scaling mode to use when displaying the video. The default value of this property is STSVideoScalingModeAspectFit. This property only works when current video is not 360-degree.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        STSVideoScalingMode videoScalingMode;

    Swift

    var videoScalingMode: Int32 { get set }
  • The index of the current playlist item. If the player view are not playing a playlist (e.g., playing a video or alive), returns NSNotFound.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSInteger currentItemIndex;

    Swift

    var currentItemIndex: Int { get }
  • The items in the current playlist.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable)
        NSArray<STSPlaylistItem *> *playlistItems;

    Swift

    var playlistItems: [STSPlaylistItem]? { get }
  • The current playlist.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) STSPlaylist *playlist;

    Swift

    var playlist: STSPlaylist? { get }
  • The current playing video.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) STSVideo *video;

    Swift

    var video: STSVideo? { get }
  • The currently playing live.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) STSLive *live;

    Swift

    var live: STSLive? { get }
  • A boolean value indicates whether current live stream is in low latency mode.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isInLowLatencyMode;

    Swift

    var isInLowLatencyMode: Bool { get }
  • A boolean value indicates whether the playback is in live DVR mode.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isInDvrMode;

    Swift

    var isInDvrMode: Bool { get }
  • A boolean value indicates whether the audio session is interrupted. Some of the player view methods will not work when this property is YES, see the description of each method for details.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL audioSessionIsInterrupted;

    Swift

    var audioSessionIsInterrupted: Bool { get }
  • A boolean value indicates whether the audio output is muted.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite) BOOL muted;

    Swift

    var muted: Bool { get set }
  • A float value indicates the playback speed. For VOD, the range will be in (0.0, 2.0], which is smaller or equal to 2.0, and greater than 0.0. Setting any valute out of range will be ignored. For Live, the value is not settable and is always 1.0.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite) float playbackSpeed;

    Swift

    var playbackSpeed: Float { get set }
  • The desired maximum resolution of a video that is to be downloaded. Defaults to CGSizeZero, which indicates there is no limit on the video resolution. Any other value indicates a preferred maximum video resolution. This property only applies to HTTP Live Streaming assets.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        CGSize preferredMaximumResolution;

    Swift

    var preferredMaximumResolution: CGSize { get set }
  • The size at which the visual portion of the item is presented by the player. This property can be accessed at any time, but may return a value of CGSizeZero prior to the player item becoming ready to play. You can use key-value observing to obtain the player item’s valid presentation size as early as possible.

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGSize presentationSize;

    Swift

    var presentationSize: CGSize { get }
  • JWT

    The member token got from StraaS server. Set this property to nil if the current user is a guest.

    If you update this property when the player is playing, the new value will work the next time you load a media (live, VOD, or playlist).

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite, nullable)
        NSString *JWT;

    Swift

    var jwt: String? { get set }
  • The low latency player, import it from player extension.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        id<STSPlayerPlayback> _Nonnull lowLatencyPlayer;

    Swift

    var lowLatencyPlayer: STSPlayerPlayback { get set }
  • The function for mapping the raw availableQualityNames to customize the available quality names. The customized available quality names will be displayed on the alert view controller for selecting the video quality. The raw availableQualityNames always includes auto, and may include source and other quality strings ended with p, for example: 360p, 480p, 1080p, etc. If this is nil, then the available quality names shown on the alert controller will be the same as the property availableQualityNames.

    Declaration

    Objective-C

    @property (nonatomic, copy, readwrite)
        QualityNamesMappingType _Nonnull mappingForDisplayingAvailableQualityNames;
  • The geolocation data will be logged when a video/live is playing. The logged data could be downloaded later via CMS API. Only latitude and longitude in CLLocation will be logged for now. These two values will be rounded down to eighth decimal place.

    Declaration

    Objective-C

    @property (nonatomic, strong, readwrite, nullable) CLLocation *location;

    Swift

    var location: CLLocation? { get set }
  • Loads and starts playing a specific video.

    This method won’t work if audioSessionIsInterrupted is YES.

    If the player view is playing a playlist and the current playlist contains this video, the player view will jump to the index of that video.

    Declaration

    Objective-C

    - (void)loadVideoWithId:(nonnull NSString *)videoId;

    Swift

    func loadVideo(withId videoId: String)

    Parameters

    videoId

    The ID of the video you want to load.

  • Loads and starts playing the first item of a specific playlist.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)loadPlaylistWithId:(nonnull NSString *)playlistId;

    Swift

    func loadPlaylist(withId playlistId: String)

    Parameters

    playlistId

    The id of the playlist you want to load.

  • Loads and starts playing the specified video from the given playlist.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)loadPlaylistWithId:(nonnull NSString *)playlistId
               playlistVideoId:(nullable NSString *)videoId;

    Swift

    func loadPlaylist(withId playlistId: String, playlistVideoId videoId: String?)

    Parameters

    playlistId

    The id of the playlist you want to load.

    videoId

    The id of the video you want to play in the beginning.

  • Loads and starts playing a specific live without lowLatency.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)loadLiveWithId:(nonnull NSString *)liveId;

    Swift

    func loadLive(withId liveId: String)

    Parameters

    liveId

    The ID of the live you want to load.

  • Loads and starts playing a specific live with lowLatency or not.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)loadLiveWithId:(nonnull NSString *)liveId lowLatency:(BOOL)isLowLatency;

    Swift

    func loadLive(withId liveId: String, lowLatency isLowLatency: Bool)

    Parameters

    liveId

    The ID of the live you want to load.

    isLowLatency

    A boolean value indicates whether to play low latency live stream. Set lowLatency to YES can significantly reduce the live latency between broadcaster and viewers but no adaptive playback. Currently, 360 low latency playback is not supported yet. When this flag is true and effective, availableQualityNames, currentQualityName and setMediaQuality will be nil.

  • Play a playlist item at the given index.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)playItemAtIndex:(NSInteger)index;

    Swift

    func playItem(at index: Int)

    Parameters

    index

    The index of the target item in the current playlist.

  • Play the next item in the current playlist.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)playNextItem;

    Swift

    func playNextItem()
  • Play the previous item in the current playlist.

    This method won’t work if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)playPreviousItem;

    Swift

    func playPreviousItem()
  • Toggle player between play and pause.

    This method won’t work if audioSessionIsInterrupted is NO.

    Declaration

    Objective-C

    - (void)togglePlayPause;

    Swift

    func togglePlayPause()
  • Sets the current playback time to the specified time.

    This method won’t work if the current playing media is a live, or if audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)seekToTime:(float)timeInSeconds;

    Swift

    func seek(toTime timeInSeconds: Float)

    Parameters

    timeInSeconds

    The time to which to seek.

  • Sets the current playback time to the live edge and plays automatically.

    This method won’t work under the following conditions: (1) If the current playing media is not a live. (2) If isInLowLatencyMode is YES. (3) If audioSessionIsInterrupted is YES.

    Declaration

    Objective-C

    - (void)playAtLiveEdge;

    Swift

    func playAtLiveEdge()
  • Gets the current time of current media.

    currentTime means the media playing time. At the beginning of a media, this value would be 0. If you play/seek to 30s from the beginning, this value would be 30. (and so on…) Get this value from STSPlayerPlaybackEventDelegate playerView:playerView mediaCurrentTimeChanged: is recommended.

    Declaration

    Objective-C

    - (NSTimeInterval)currentTime;

    Swift

    func currentTime() -> TimeInterval

    Return Value

    The current time (in seconds) of current media.

  • Gets the current live date time of current media.

    If a live was started at 2017/7/1, 12:00:00(whose timestamp is 1498910400), playing its VoD will have 1498910400 currentLiveDateTime at the beginning. If you play/seek to 30s from the VoD’s beginning, this value would become 1498910430 (1498910400 + 30). Only VoD created from live would have valid value, else would get 0. Get this value from STSPlayerPlaybackEventDelegate playerView:playerView mediaCurrentTimeChanged: is recommended.

    Declaration

    Objective-C

    - (NSTimeInterval)currentLiveDateTime;

    Swift

    func currentLiveDateTime() -> TimeInterval

    Return Value

    The current live date time (in unix seconds) of current media. Return 0 if current media is not mapped to any date.

  • Gets the CCU of the currently playing live.

    Declaration

    Objective-C

    - (NSNumber *_Nullable)ccuOfCurrentlyPlayingLive;

    Swift

    func ccuOfCurrentlyPlayingLive() -> NSNumber?

    Return Value

    the CCU of the currently playing live. Returns nil if there is no live playing.

  • Gets the hitCount of the the currently playing live.

    Declaration

    Objective-C

    - (NSNumber *_Nullable)hitCountOfCurrentlyPlayingLive;

    Swift

    func hitCountOfCurrentlyPlayingLive() -> NSNumber?

    Return Value

    the hitCount of the currently playing live. Returns nil if there is no live playing.

  • Gets the broadcast start time of the currently playing live stream.

    Declaration

    Objective-C

    - (NSNumber *_Nullable)broadcastStartTimeOfCurrentlyPlayingLive;

    Swift

    func broadcastStartTimeOfCurrentlyPlayingLive() -> NSNumber?

    Return Value

    The broadcast start time in millisecond of of the currently playing live stream. Returns nil if the live stream is stopped or if there is no live playing.

  • Get the raw quality names of the current playing media (Live or VOD). Return nil when playing a live and lowLatency is true and effective.

    Declaration

    Objective-C

    - (NSArray *_Nullable)availableQualityNames;

    Swift

    func availableQualityNames() -> [Any]?

    Return Value

    The name of the available qualities.

  • Get the current selected quality name of the playing media (Live or VOD). Return nil when playing a live and lowLatency is true and effective.

    Declaration

    Objective-C

    - (NSString *_Nullable)currentQualityName;

    Swift

    func currentQualityName() -> String?

    Return Value

    The name of the current selected quality.

  • Switch player to the given media quality. Note: Load a new media will reset the media quality to auto. Return NO when playing a live and lowLatency is true and effective.

    Declaration

    Objective-C

    - (BOOL)setMediaQuality:(nonnull NSString *)qualityName;

    Swift

    func setMediaQuality(_ qualityName: String) -> Bool

    Parameters

    qualityName

    The name of the media quality you want switch to.

    Return Value

    YES if the media quality did change to the target quality; otherwise, NO.

  • Change server domain name. This is for CDN customization scenario such as china access.

    NOTE: If the startListeningLiveEvent method has been called, it should be called again to make sure the new custom host is applied to it. - parameter: customHost The new host to be applied. - returns: YES if apply new custom host to API requests successfully; otherwise, NO.

    Declaration

    Objective-C

    - (BOOL)setCustomHost:(nonnull NSString *)customHost;

    Swift

    func setCustomHost(_ customHost: String) -> Bool

    Parameters

    customHost

    The new host to be applied.

    Return Value

    YES if apply new custom host to API requests successfully; otherwise, NO.