Simplify API calls to find the best server and region to publish and subscribe to. For security reasons all calls will return a JWT token for authentication including the required socket path to connect with.
You will need your own Publishing token and Stream name, please refer to Managing Your Tokens.
- Source
Methods
(inner) getEndpoint() → {String}
Get current Director API endpoint where requests will be sent. Default endpoint is 'https://director.millicast.com'.
- Source
API base url
- Type:
- String
(inner) getLiveDomain() → {String}
Get current Websocket Live domain. By default is empty which corresponds to not parse the Director response.
- Source
Websocket Live domain
- Type:
- String
(inner) getPublisher(options) → {Promise.<MillicastDirectorResponse>}
Get publisher connection data.
Name | Type | Description |
---|---|---|
options | DirectorPublisherOptions | Millicast options. |
- Source
Promise object which represents the result of getting the publishing connection path.
- Type:
- Promise.<MillicastDirectorResponse>
const response = await Director.getPublisher(options)
import { Publish, Director } from '@millicast/sdk'
//Define getPublisher as callback for Publish
const streamName = "My Millicast Stream Name"
const token = "My Millicast publishing token"
const tokenGenerator = () => Director.getPublisher({token, streamName})
//Create a new instance
const millicastPublish = new Publish(streamName, tokenGenerator)
//Get MediaStream
const mediaStream = getYourMediaStreamImplementation()
//Options
const broadcastOptions = {
mediaStream: mediaStream
}
//Start broadcast
await millicastPublish.connect(broadcastOptions)
(inner) getSubscriber(options) → {Promise.<MillicastDirectorResponse>}
Get subscriber connection data.
Name | Type | Description |
---|---|---|
options | DirectorSubscriberOptions | Millicast options. |
- Source
Promise object which represents the result of getting the subscribe connection data.
- Type:
- Promise.<MillicastDirectorResponse>
const response = await Director.getSubscriber(options)
import { View, Director } from '@millicast/sdk'
//Define getSubscriber as callback for Subscribe
const streamName = "My Millicast Stream Name"
const accountId = "Millicast Publisher account Id"
const tokenGenerator = () => Director.getSubscriber({streamName, accountId})
//... or for an secure stream
const tokenGenerator = () => Director.getSubscriber({streamName, accountId, subscriberToken: '176949b9e57de248d37edcff1689a84a047370ddc3f0dd960939ad1021e0b744'})
//Create a new instance
const millicastView = new View(streamName, tokenGenerator)
//Set track event handler to receive streams from Publisher.
millicastView.on('track', (event) => {
addStreamToYourVideoTag(event.streams[0])
})
//View Options
const options = {
}
//Start connection to broadcast
await millicastView.connect(options)
(inner) setEndpoint(url) → {void}
Set Director API endpoint where requests will be sent.
Name | Type | Description |
---|---|---|
url | String | New Director API endpoint |
- Source
- Type:
- void
(inner) setLiveDomain(domain) → {void}
Set Websocket Live domain from Director API response. If it is set to empty, it will not parse the response.
Name | Type | Description |
---|---|---|
domain | String | New Websocket Live domain |
- Source
- Type:
- void
Type Definitions
DRMObject
- Object
Name | Type | Description |
---|---|---|
fairPlayCertUrl | String | URL of the FairPlay certificate server. |
fairPlayUrl | String | URL of the FairPlay license server. |
widevineUrl | String | URL of the Widevine license server. |
- Source