Getting started with Millicast for iOS
Dolby Millicast delivers broadcast quality live streaming at sub-second latency, enabling interactivity and fan engagement. Using the THEOplayer Millicast integration, you can play your Millicast streams directly through THEOplayer.
Usage
- Follow our Getting Started guide to set up THEOplayer in your iOS app.
- Add the
THEOplayer-Integration-Millicast
dependency to your project. - Add the
THEOplayerMillicastIntegration
to the player. - Add a
MillicastSource
to your player's source.
Add the THEOplayer-Integration-Millicast
dependency
Add the Millicast integration as a dependency in to your project:
- Swift Package Manager
- Cocoapods
.package(url: "https://github.com/THEOplayer/theoplayer-sdk-apple.git", from: "8.10.0")
.product(name: "THEOplayerMillicastIntegration", package: "theoplayer-sdk-apple")
pod 'THEOplayer-Integration-Millicast', '~> 8.10'
Add the Millicast integration to the player
First import the integration into your project:
import THEOplayerMillicastIntegration
Create and add the THEOplayerMillicastIntegration
to your THEOplayer
:
let millicastIntegration = MillicastIntegrationFactory.createIntegration()
theoplayer.addIntegration(millicastIntegration)
Add a MillicastSource
After setting up a THEOplayer
in your app, set its source to a SourceDescription
containing a MillicastSource
.
You'll need a Millicast account ID and stream name to identify your Millicast stream:
let millicastSource = SourceDescription(source: MillicastSource(streamName: "multiview", accountID: "k9Mwad"))
theoplayer.source = millicastSource
Make sure to replace the above streamName
and accountID
with your own. If your source is a secure stream, then you will
also need to add a subscriber token to the source as follows:
MillicastSource(streamName: ..., accountID: ..., token: "Your token")
Add configuration
Optionally, you can provide additional configuration to the source, specific for working with Millicast streams.
To configure these settings, add a MCClientOptions
object as the connectOptions
parameter of the source object
and specify the options.
In the example below, the configuration is used to disable any audio from the Millicast stream. For an exhaustive list of these options, visit the documentation.
let connectOptions: MCClientOptions = .init()
connectOptions.disableAudio = true
MillicastSource(streamName: ..., accountID: ..., connectOptions: connectOptions)
Background playback
In order to play Millicast sources in the background, ensure you've configured a backgroundPlaybackDelegate
on the player. A simple example for always allowing background playback is shown below:
class BackgroundDelegate: BackgroundPlaybackDelegate {
func shouldContinueAudioPlaybackInBackground() -> Bool {
return true
}
}
theoplayer.backgroundPlaybackDelegate = BackgroundDelegate()