stream-player-temp
v1.1.28
Published
This module provides configuration and utility functions for interacting with Isometrik's API and MQTT services. The configuration is dynamically loaded from a global configuration object, which allows it to be easily customized for different projects.
Downloads
86
Readme
Project Configuration and API Utilities
This module provides configuration and utility functions for interacting with Isometrik's API and MQTT services. The configuration is dynamically loaded from a global configuration object, which allows it to be easily customized for different projects.
Configuration
The configuration properties are loaded from the global window.__stream_player_config object. Ensure this object is not altered in your project.
Example Configuration Object
- isometrikBaseApiUrl:
"https://apis.isometrik.io"
- baseApiUrl:
"https://api.soldlive.eu"
- liveKitUrl:
"wss://streaming.isometrik.io"
- MQTTHost:
"connections.isometrik.io"
- projectCreds:
- accountId:
"652f9ad3e24477cce4a025d5"
- projectId:
"88cad458-e9a0-4109-a2d6-df520e56b4f7"
- keySetId:
"b17b380d-153e-4017-8a8f-26b61f5c23c8"
- licenseKey:
"lic-IMKm3wNSIeSnxmdj/lOy4mB55sziy2A1NhU"
- appSecret:
"SFMyNTY.g3QAAAACZAAEZGF0YXQAAAADbQAAAAlhY2NvdW50SWRtAAAAGDY1MmY5YWQzZTI0NDc3Y2NlNGEwMjVkNW0AAAAIa2V5c2V0SWRtAAAAJGIxN2IzODBkLTE1M2UtNDAxNy04YThmLTI2YjYxZjVjMjNjOG0AAAAJcHJvamVjdElkbQAAACQ4OGNhZDQ1OC1lOWEwLTQxMDktYTJkNi1kZjUyMGU1NmI0ZjdkAAZzaWduZWRuBgAyh_ZBiwE.u0RqujyPa8EB036aYWH50kME2sMLgjC7faUtYTJxHFM"
- userSecret:
"SFMyNTY.g3QAAAACZAAEZGF0YXQAAAADbQAAAAlhY2NvdW50SWRtAAAAGDY1MmY5YWQzZTI0NDc3Y2NlNGEwMjVkNW0AAAAIa2V5c2V0SWRtAAAAJGIxN2IzODBkLTE1M2UtNDAxNy04YThmLTI2YjYxZjVjMjNjOG0AAAAJcHJvamVjdElkbQAAACQ4OGNhZDQ1OC1lOWEwLTQxMDktYTJkNi1kZjUyMGU1NmI0ZjdkAAZzaWduZWRuBgAyh_ZBiwE.nWn8_aZvCwqH1smL9Mp8tgYeG4S04WWSrbwczusX5Cg"
- accountId:
- userProfileData:
- userId & _id
- name
- firstName
- lastName
- profilePic
- senderIdentifier
- isomatricChatUserId
- streamData:
- status:
"STARTED"/"SCHEDULED"/"ENDED"
- isScheduledStream
- streamId
- _id
- metaData
- isStreamActive
- streamDescription
- status:
- noUserCallBack:
() => {}
- alertFunction:
() => {}
Exported Configuration Properties
ISOMETRIK_BASE_API_URL (isometrikBaseApiUrl)
This constant holds the base URL for the Isometrik API, loaded from the configuration.
BASE_API_URL (baseApiUrl)
This constant holds the base URL for project API, loaded from the configuration.
PROJECTS_CREDS configProps('projectCreds')
This constant holds the project credentials required for API and MQTT authentication, loaded from the configuration.
noUserCallBack
This function handles restriction middleware It is used if stream viewer is a guest and u want to add some type of restriction Tries to buy a product you can move it to signIn screen / dialog
const noUserCallBack = () => { document.getElementById('profile_svg_header')?.click(); } const alertFunction = (type, data) => { if (type == 'showSnackbar') { showSnackbar(data); } }
Isometrik MQTT Credentials
The MQTT credentials are constructed using the project credentials. These credentials are used to connect to the Isometrik MQTT broker.
ISOMETRIK_MQTT_CREDS
const ISOMETRIK_MQTT_CREDS = { URL: 'connections.isometrik.io', Username: '2' + PROJECTS_CREDS.accountId + PROJECTS_CREDS.projectId, Password: PROJECTS_CREDS.licenseKey + PROJECTS_CREDS.keySetId, API_URL: 'https://apis.isometrik.io', };
MQTT Topics
The MQTT topics are constructed using the project credentials. These topics are used to subscribe to various events and messages.
ISOMETRIK_MQTT_TOPICS
const ISOMETRIK_MQTT_TOPICS = {
Message: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/Message/
,
PresenceEvents: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/Status/
,
NewMessageEvent: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/
,
userEvents: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/Users/
,
};
Utility Functions
getUrl(endpoint)
A function to construct the full API URL for a given endpoint.
const getUrl = (endpoint) => { return ISOMETRIK_BASE_API_URL + endpoint; };
Common Headers
The common headers required for API requests, including authorization details.
const commonHeader = { licenseKey: PROJECTS_CREDS.licenseKey, appSecret: PROJECTS_CREDS.appSecret, "Content-Type": "application/json" };
getIsometrik(endpoint, otherHeaders)
An asynchronous function to make GET requests to the Isometrik API with the necessary headers.
const getIsometrik = async (endpoint = "", otherHeaders = {}) => fetch(getUrl(endpoint), { method: "GET", headers: { ...commonHeader, ...otherHeaders, }, }); Usage Ensure your project includes the necessary configuration in window.__stream_player_config. Import the module and use the provided constants and functions as needed.