website logo
Request an API key
⌘K
πŸš€Introduction
🏒Org Set Up
πŸ„Creator Onboarding
πŸ› οΈStream Creation
πŸ–₯️Dashboard
πŸŽ™οΈStreams
πŸ“½οΈCreator Audio and Video
πŸ“šMedia Integration
πŸ—¨οΈChat
πŸ“ˆPolls, Points, & Leaderboards
πŸ€™Guest Call-In
🀫Moderator tools
πŸ–ΌοΈPicture-In-Picture
πŸ’°Monetization
🏦Tipping or In-App purchases
βœ‹Paywalls
πŸ›’Products (Live Shopping)
πŸ’΅Ads
🌐Integrations & SDKs
πŸŽ›οΈAPI
Android SDK
iOS SDK
Javascript SDK
🎨Custom Themes
πŸ“ŠSDK Analytics
πŸ”‘Single Sign-On (SSO) (BETA)
πŸ””Webhooks (BETA)
πŸ‘­Social Features
πŸ“½οΈRecordings & Content Management
🏷️Custom Fields & Tags
πŸ“œChangelog
βŒ›Usage Limits & Recommendations
Docs powered byΒ archbeeΒ 

Using Your Own Player (iOS)

HotMicMediaPlayer allows you to integrate your own player into your application. In order do to this, you must:

  • Include the player in your application to be played. (e.g. Bitmovin, JWPlayer, Exo).
  • Use our protocol to forward commands to your player when the HotMic protocol dictates (e.g. pause the player).
  • Send to HotMic various player events (e.g. notify HotMic the player is paused).

The HMPlayer protocol defines variables and functions you must implement in order to provide a custom player. Your implementation must also store a reference to an HMPlayerDelegate and call its functions to inform the delegate when various events occur.

Provide a view to display on-screen.

Swift
|
var view: UIView { playerView }
ο»Ώ

Provide the playing status.

Swift
|
var isPlaying: Bool { player.isPlaying }
ο»Ώ

Provide the paused status.

Swift
|
var isPaused: Bool { player.isPaused }
ο»Ώ

Provide the seeking status.

Swift
|
var isSeeking: Bool { activelySeeking }
ο»Ώ

Provide the mute status.

Swift
|
var isMuted: Bool { player.isMuted }
ο»Ώ

Provide the current audio level as a value between 0 and 100.

Swift
|
var volume: Int { player.volume }
ο»Ώ

Provide the total duration in seconds of the VoD stream or infinity if it’s a live stream.

Swift
|
var duration: TimeInterval { player.duration }
ο»Ώ

Provide the current playback position in seconds. For a VoD stream, the time ranges between 0 and the duration of the asset. For a live stream, the time is a Unix timestamp denoting the current playback position.

Swift
|
var time: TimeInterval { player.currentTime }
ο»Ώ

Provide the current playback rate as a value between 0 and 2.

Swift
|
var playbackSpeed: Float { player.playbackSpeed }
ο»Ώ

Store the delegate in a weak optional variable to call its functions in the future.

Swift
|
func setDelegate(_ delegate: HMPlayerDelegate) { self.delegate = delegate }
ο»Ώ

Invoke play.

Swift
|
func play() { player.play() }
ο»Ώ

Invoke pause.

Swift
|
func pause() { player.pause() }
ο»Ώ

Turn on volume muted.

Swift
|
func mute() { player.mute() }
ο»Ώ

Turn off volume muted.

Swift
|
func unmute() { player.unmute() }
ο»Ώ

Change the audio level.

Swift
|
func updateVolume(_ volume: Int) { player.volume = volume }
ο»Ώ

Seek to the given playback position for the VoD stream.

Swift
|
func seek(to time: TimeInterval) {
    guard !player.isLive else { return }
    
    player.seek(time: time)
}
ο»Ώ

Seek by the given time shift offset in seconds from the live edge for the live stream, or seek to the current time plus the given time shift offset for the VoD stream. Return an HMPlayerLiveTimeShiftError if the new time shift is too far behind or ahead of the live position.

Swift
|
@discardableResult func seek(by timeShiftOffset: TimeInterval) -> HMPlayerLiveTimeShiftError? {
    guard player.isLive else {
        seek(to: time + timeShiftOffset)
        return nil
    }
    
    let newTimeShift = player.timeShift + timeShiftOffset
    
    guard newTimeShift >= player.maxTimeShift else {
        player.timeShift = 0
        return .tooFarBehind
    }
    guard newTimeShift <= 0 else {
        player.timeShift = 0
        return .tooFarAhead
    }
    
    player.timeShift = newTimeShift
    return nil
}
ο»Ώ

Seek the live stream to its 'now' playback time.

Swift
|
func seekToLive() { player.timeShift = 0 }
ο»Ώ

Change the playback rate. A value between 0 and 1 enables slow motion and a value between 1 and 2 enables fast forward.

Swift
|
func updatePlaybackSpeed(_ playbackSpeed: Float) { player.playbackSpeed = playbackSpeed }
ο»Ώ

Prepare for device rotation to begin.

Swift
|
func beginRotation() { playerView.willRotate() }
ο»Ώ

Handle device rotation ended.

Swift
|
func endRotation() { playerView.didRotate() }
ο»Ώ

Prepare to enter fullscreen mode.

Swift
|
func enterFullscreen() { playerView.enterFullscreen() }
ο»Ώ

Prepare to exit fullscreen mode.

Swift
|
func exitFullscreen() { playerView.exitFullscreen() }
ο»Ώ

Player Delegate

The HMPlayerDelegate protocol defines functions your HMPlayer implementation calls to inform HotMic when various events occur.

Inform the delegate the player invoked play with intention to start/resume playback.

Swift
|
delegate?.playerDidInvokePlay(self)
ο»Ώ

Inform the delegate the player state changed to playing.

Swift
|
delegate?.playerPlaying(self)
ο»Ώ

Inform the delegate the player state changed to paused.

Swift
|
delegate?.playerPaused(self)
ο»Ώ

Inform the delegate the player state changed to buffering.

Swift
|
delegate?.playerBuffering(self)
ο»Ώ

Inform the delegate the player finished seeking in a live stream by adjusting the time shift.

Swift
|
delegate?.playerDidFinishSeekByTimeShift(self)
ο»Ώ

Inform the delegate the player recovered from a stall due to sufficient buffer.

Swift
|
delegate?.playerDidRecoverFromStall(self)
ο»Ώ

Inform the delegate the player's playback position changed.

Swift
|
delegate?.player(self, timeChanged time: player.currentTime)
ο»Ώ

Inform the delegate the player's duration changed.

Swift
|
delegate?.player(self, durationChanged duration: player.duration)
ο»Ώ

Inform the delegate the player encountered an error.

Swift
|
delegate?.player(self, errorOccurredWithCode code: error.code, message: error.localizedDescription)
ο»Ώ

ο»Ώ

Updated 03 Mar 2023
PREVIOUS
iOS SDK
NEXT
Javascript SDK
Docs powered byΒ archbeeΒ 
TABLE OF CONTENTS
Player Delegate