Integrations & SDKs
iOS SDK
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 var view uiview { playerview } provide the playing status var isplaying bool { player isplaying } provide the paused status var ispaused bool { player ispaused } provide the seeking status var isseeking bool { activelyseeking } provide the mute status var ismuted bool { player ismuted } provide the current audio level as a value between 0 and 100 var volume int { player volume } provide the total duration in seconds of the vod stream or infinity if itβs a live stream 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 var time timeinterval { player currenttime } provide the current playback rate as a value between 0 and 2 var playbackspeed float { player playbackspeed } store the delegate in a weak optional variable to call its functions in the future func setdelegate( delegate hmplayerdelegate) { self delegate = delegate } invoke play func play() { player play() } invoke pause func pause() { player pause() } turn on volume muted func mute() { player mute() } turn off volume muted func unmute() { player unmute() } change the audio level func updatevolume( volume int) { player volume = volume } seek to the given playback position for the vod stream 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 @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 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 func updateplaybackspeed( playbackspeed float) { player playbackspeed = playbackspeed } prepare for device rotation to begin func beginrotation() { playerview\ willrotate() } handle device rotation ended func endrotation() { playerview\ didrotate() } prepare to enter fullscreen mode func enterfullscreen() { playerview\ enterfullscreen() } prepare to exit fullscreen mode 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 delegate? playerdidinvokeplay(self) inform the delegate the player state changed to playing delegate? playerplaying(self) inform the delegate the player state changed to paused delegate? playerpaused(self) inform the delegate the player state changed to buffering delegate? playerbuffering(self) inform the delegate the player finished seeking in a live stream by adjusting the time shift delegate? playerdidfinishseekbytimeshift(self) inform the delegate the player recovered from a stall due to sufficient buffer delegate? playerdidrecoverfromstall(self) inform the delegate the player's playback position changed delegate? player(self, timechanged time player currenttime) inform the delegate the player's duration changed delegate? player(self, durationchanged duration player duration) inform the delegate the player encountered an error delegate? player(self, erroroccurredwithcode code error code, message error localizeddescription)