Integrations & SDKs
Android SDK
Using Your Own Player (Android)
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) for using a custom player, the implementation should do the following extend their custom player to support the basehmplayer implementation implement the playercallback getplayer() function basehmplayer interface this code shows the different values and functions in the basehmplayer interface if you have any questions about this, please contact our team / hotmic player interface / interface basehmplayer { / return the tag that was passed to the player by the sdk / val playertag string / initialize the player and load the media url @param url media url to be loaded / fun load(url string?) / return the player view ensure that the player view does not, by default, show any inbuilt controls / val playerview view / returns pdt of the feed / val time long / returns the current position of the video (in ms) / val position long / returns true if the video is playing / val isplaying boolean / get/sets the audio volume as an integer between 0 and 100 (0 being mute) / var volume int / returns true if the player was muted note vol = 0 is not necessarily muted / val ismuted boolean / mutes/unmutes the audio, unmuting the video should restore the volume to what the set volume earlier was and not the max value / fun mute(mute boolean) / play the video / fun play() / pauses the video / fun pause() / returns true if the media that the player is playing is live / val islivecontent boolean / returns the player progress info, incl the total video duration, current position, buffered position / fun getprogress() hmplayerprogress / sets the player to play the video in the given play rate a normal play will be 1 0 / fun setplayrate(rate double) / returns the current state of the player idle/playing/ready/buffering/ended/error / val playstate hmplayerstate / seeks the video timeline by the given offset a positive offset will seek forward @param offsetaddedinms offset, in milliseconds, to be added to the timeline / fun seektooffset(offsetaddedinms long) / seeks the video directly to the given position @param newposition position, in millisecond, to jump to / fun seekto(newposition long) / close the player release the player and all params reset / fun close() } player callback interface this function is how you define whether you want to use a custom, third party player, or the default one implement the getplayer function in the callback to return a custom player returning null will result in the sdk using the inbuilt exo player implementation / optional if your implementation wants to use a custom player, then ooverride this method to construct and return the player @param context @param tag string to identify the player the implementation has to return this string in the basehmplayer tag variable @param listener callbacks that the player implementation should call on media state change or error @return custom implementation which implements basehmplayer if null, then default exoplayer will be used / fun getplayer( context context, tag string, listener hmplayereventlistener ) basehmplayer? { return null } other supporting classes for your reference, these are other classes which may be helpful with your custom player implementation player event listener / listener, which defines the callbacks to be called when the player implementation encounters certain events like state change, error / interface hmplayereventlistener { / on encountering any kind of error, the player implementation should classify the error and then call this method @param tag tag associated with the player, useful when there are multiple players, use the same tag that was provided to teh player implementation by the player @param error type and details of the error encountered by the player / fun onplayererror(tag string, error hmplayererror) / callback triggered when there is a play state change in the player the player implementation should classify the state to one of the recognized states @param tag tag associated with the player, useful when there are multiple players, use the same tag that was provided to teh player implementation by the player @param mediastate / fun onmediastatechanged(tag string, mediastate hmplayerstate) } player error class / holds details of the error encountered by the player / data class hmplayererror( / type of error / val type hmplayererrortype, / error code returned by the player if an error message is shown to this user, then this detail will be included in it / val responsecode string, / any debugging data can be added in this field this will be passed to analytics / val analyticreason string = "", / optional for overwriting the default error message this would be displayed to the user / var displaymessage string? = null ) player error type enum enum class hmplayererrortype( //player will try implicit retry at defined intervals val autoretry boolean, //string resource for the message to be displayed to the user val messageresid int ){ / network error for reference the following exo player errors will fall in this category error code timeout, error code io unspecified, error code io network connection failed, error code io network connection timeout, error code io bad http status, / error not recognized / err unknown(false, r string err player general), error code io invalid http content type / err network conn(true, r string err player network), / media file was not found or no permission to fetch file for reference the following exo player errors will fall in this category error code io file not found, error code io no permission / err media not found(true, r string err player general), / media format is not correct or is corrupted decoding failure for reference the following exo player errors will fall in this category error code decoder init failed, error code decoder query failed, error code decoding failed, error code decoding format exceeds capabilities, error code decoding format unsupported / err invalid content(false, r string err player general no retry), / loading position falling behind the sliding window of available live content for reference the following exo player errors will fall in this category error code behind live window / err behind live window(true, r string err player general), / player is in an unexpected state, possibly due to malformed hls this happens usually at the start and end of the live hls stream player will not show this error to the user, it will wait while it keeps retrying for reference the following exo player errors will fall in this category error code parsing manifest malformed, error code parsing container malformed, error code parsing container unsupported, error code parsing manifest unsupported / err player onhold(true, r string err player general) } player state enum enum class hmplayerstate { / player is idle, no url loaded / media idle, / player is playing, time line is moving / media playing, / player is ready to play, but possibly paused / media ready, / player is buffering media / media buffering, / player has finished playing the data / media ended, / error encountered while trying to play / media error } player progress data / for any given point of time, this construct will hold the video progress details like the duration, current position of the video player / data class hmplayerprogress( / total duration of the video in milliseconds / val duration long = 0l, / current position of the video in milliseconds / val currentposition long = 0l, / estimate of the position in the current content up to which data is buffered, in milliseconds / val bufferedposition long = 0l, / true if the player is currently seeking to a new position / val isseeking boolean = false, )