Skip to main content

Getting started

Step 1: Set up the development environment​

What you need before starting​

  • Your AWS account must be SSO-enabled to access https://deltatre.awsapps.com/start. After SSO is enabled (please refer to your Project Manager), restart your development machine.

Setup​

  1. Access https://deltatre.awsapps.com/start and select Access keys.
AWS access portal
  1. In a terminal, execute the three imports in Option 1: Set AWS environment variables.
Set AWS environment variables
  1. Go back to https://deltatre.awsapps.com/start and select CodeArtifactReadOnlyAccessDIVA.
CodeArtifact ReadOnly Access Diva
  1. Search for and select CodeArtifact.
CodeArtifact service
  1. Download and install AWS CLI: follow the instructions on the AWS CLI installation page for your operating system. AWS CLI v2 is recommended.
    Once installed, you can verify the installation by running:
aws --version
  1. Run AWS Configure: open your terminal and run the following command:
aws configure
  1. Enter your AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, Default region name, and Default output format when prompted.

  2. Configure your Swift client using this AWS CLI CodeArtifact command. The login command fetches an authorization token from CodeArtifact using your AWS credentials and lasts 12 hours. It configures Swift for use with CodeArtifact by editing ~/.swiftpm/configuration/registries.json and updating the credentials. Inside the JSON file, you should see the diva registry. This tells SPM to search for dependencies using the AWS package registry service.

    To do this, you need an existing package already downloaded on your local machine. Open a terminal in the folder where the Package.swift file is located and paste the credentials you received from Option 1: Set AWS environment variables. It should look like this:

export AWS_ACCESS_KEY_ID="123"
export AWS_SECRET_ACCESS_KEY="abc"
export AWS_SESSION_TOKEN="==sd45f65sd4f56sd4f6sd465fa"
  1. Check your domain-owner identifier with the following command:
aws sts get-caller-identity --query Account --output text
  1. Download the required package (DivaIOS or DivaTVOS) with the following command:
aws codeartifact get-package-version-asset \
--domain "deltatre-diva" \
--domain-owner "<domain-owner>" \
--repository "Diva" \
--format generic \
--namespace "diva" \
--package "<package-name (DivaIOS/DivaTVOS)>" \
--package-version "<version>" \
--asset "<asset-name (DivaIOS/DivaTVOS)>.zip" \
--region "eu-central-1" \
<output-name>.zip

Step 2: Migrate the package integration​

Overview​

Starting with Diva 5.12.0, the Diva Swift Package integration has been simplified. Version 5.12.x consolidates the Diva integration under a single DivaIOS/DivaTVOS module.

Previously, the package explicitly exposed individual Diva framework targets:

targets: [
"DivaAdsBeaconing",
"DivaAdsCore",
"DivaBOAdapter",
"DivaCore",
"DivaConvivaMediaAnalytics",
"DivaDefinitions",
"DivaIOS",
"DivaGooglePalAnalytics",
"DivaOMAnalytics",
"OMSDK_Deltatre",
"MD360Player4iOS",
"ProgrammaticAccessLibrary",
"SWXMLHash"
]

From 5.12.0, the Diva-specific targets are consolidated under DivaIOS/DivaTVOS:

targets: [
"DivaIOS", //DivaTVOS
"OMSDK_Deltatre",
"ProgrammaticAccessLibrary",
"YouboraLib",
"ConvivaAVFoundation",
"ConvivaSDK",
],

Removed direct Diva binary targets​

The local .binaryTarget declarations for the following Diva modules have been removed:

  • DivaAdsBeaconing
  • DivaAdsCore
  • DivaBOAdapter
  • DivaConvivaMediaAnalytics
  • DivaCore
  • DivaDefinitions
  • DivaGooglePalAnalytics
  • DivaOMAnalytics

There is no longer any need to add or manage these modules as individual dependencies.

Installation​

You can import the DivaIOS/DivaTVOS xcframework into your Xcode project by adding it as a framework dependency.

Required source-code changes​

Existing integrations that directly import or reference types using the previous Diva module names must be updated. Use DivaIOS/DivaTVOS as the module import and namespace.

Replace imports of individual Diva modules with:

import DivaIOS/DivaTVOS

Before:

import DivaCore

From 5.12.0:

import DivaIOS/DivaTVOS

Apply the same change to any source files that import other Diva modules that are no longer exposed individually.

Update module-qualified type references​

References that explicitly use a previous module name as a namespace must also be changed to DivaIOS/DivaTVOS.

Before:

init?(_ event: DivaCore.AnalyticsEvent) {
// ...
}

From 5.12.0:

init?(_ event: DivaIOS(DivaTVOS).AnalyticsEvent) {
// ...
}

This applies to all module-qualified references to Diva APIs that have moved under the DivaIOS/DivaTVOS module.

Migration checklist​

  1. Update the Diva package dependency to version 5.12.x.
  2. Remove direct dependencies on the Diva frameworks that are no longer exposed as individual binary targets.
  3. Replace imports of removed Diva modules with import DivaIOS/DivaTVOS.
  4. Replace module-qualified references, for example DivaCore.AnalyticsEvent → DivaIOS(DivaTVOS).AnalyticsEvent.

Step 3: Write your very first iOS/tvOS app with DIVA Player​

What you need before starting​

  • Ensure the DIVA Back Office instance you rely on is running.
  • Ask your video engineering team for the videoId and settings values.

Instantiation​

Replace videoId and settings with the values provided by your video engineering team in the following code. For every property you can set on DivaConfiguration (iOS) and DivaTVConfiguration (tvOS), see the Configuration reference.


class ExampleVideoMetadataProvider {

}

extension ExampleVideoMetadataProvider: VideoMetadataProvider {
func requestVideoMetadata(
videoId: String,
currentVideoMetadata: VideoMetadata?,
playbackState: PlaybackState
) async throws -> VideoMetadata {
SWVideoMetadataCleanModel.make(
videoId: videoId,
title: "title",
image: "https://www.image.jpg",
eventId: "eventId",
programDateTime: "2018-07-15T13:40:15.681Z",
trimIn: 0,
trimOut: 100,
assetState: .vod,
ad: "https://divademo.deltatre.net/DIVAProduct/www/Data/Vast/skippable2.xml",
sources: [
SWVideoSourceCleanModel.make(
uri: "https://vod-ffwddevamsmediaservice.streaming.mediaservices.windows.net/6e8b64ef-feb3-4ea9-9c63-32ef7b45e1dd/6e8b64ef-feb3-4ea9-9c63-32ef7b45.ism/manifest(format=m3u8-aapl,filter=hls)",
format: "HLS"
)
],
audioTracks: [SWAudioTrackCleanModel(_id: "English1", selector: "English", label: "English")],
defaultAudioTrackId: "English1",
dvrType: .full
)
}
}

class FullscreenViewController: UIViewController {
var diva: Diva?

override func viewDidLoad() {
super.viewDidLoad()

Diva.isDebugMode = false
Diva.mediaAnalyticsEnabled = true

var config = DivaConfiguration(
settings: settings,
dictionary: dictionary,
videoId: videoId,
videoMetadataProvider: ExampleVideoMetadataProvider()
)
config.settingsError = "Settings Error"
config.networkError = "Network Error"
config.onVideoError = { error, videoMetadata in
print("[VideoError] VideoError received for video: \(videoMetadata?.videoId ?? "unknown Id")")
print("[VideoError] error: \(error.type.rawValue) message: \(error.message)")
}
config.onAnalyticEvent = { [weak self] event in
guard self != nil else { return }
var parameters = event.eventArguments
parameters["interactive"] = "\(event.interactive)"
Analytics.logEvent(event.type, parameters: parameters)
print("[EVENT] \(event.type)")
}
config.onMediaAnalyticsUpdate = { [weak self] update in
guard self != nil else { return }
await ConvivaAnalytics.shared.handle(update)
await YouboraAnalytics.shared.handle(update)
}
config.onExit = { [weak self] in
self?.dismiss(animated: true)
}

Task { @MainActor [weak self] in
guard let self else { return }
self.diva = await Diva(configuration: config)
self.diva?.setTargetView(view: self.view, viewController: self)
}
}

deinit {
diva = nil
}
}

Step 4: Configure the live-to-VOD transition​

Available from DIVA Player iOS/tvOS 5.12.6.

When a live event ends, the video CMS finalizes it into a VOD of the same video: in the VideoMetadata the assetState goes from live to vod, usually with a new source and a trim-out. DIVA Player detects the change and reloads the video.

Use liveToVodTransitionMode to choose what the viewer sees at that moment. It's available on DivaConfiguration (iOS) and DivaTVConfiguration (tvOS): see the Configuration reference for the other properties.

ModeWhat happens
.endOfPlay (default)The behavior before 5.12.6: the VOD resumes at the viewer's position and End of Play follows the usual rules.
.restartFromZeroThe VOD plays from 0:00.
.customNotifier { context in … }The VOD loads paused and DIVA Player calls your closure once, on the main actor. Your app decides what happens next.

When the setting applies​

The setting applies only when the same video goes from live to VOD, and only if, at that moment:

  • the viewer is at the live edge, or
  • the viewer's position no longer exists in the VOD, because the trim-out cut it.

Otherwise (the viewer is behind the live edge and the position still exists in the VOD) the setting is ignored: playback resumes at the same position, no closure is called, and End of Play shows normally when the VOD ends.

The live edge is where the player shows LIVE:

  • iOS: the LIVE indicator (api.isPlaybackLive) is on, or the position is within 18 s of the end of the stream.
  • tvOS: the LIVE indicator is on.
  • AirPlay: the LIVE indicator is on, that is within 18 s of the receiver's live point (up to 48 s from the end of the stream when the receiver's offset isn't measured, Apple TV included).
ModeViewer at the live edgeViewer's position cut by the trim-out
.endOfPlayiOS: End of Play right away if the position is at the end of the player; otherwise the VOD plays its last seconds, then End of Play.
tvOS: the VOD plays to its end, then End of Play.
End of Play right away
.restartFromZeroThe VOD plays from 0:00The VOD plays from 0:00
.customNotifierThe VOD is paused at the viewer's position, then your closure is calledThe VOD is paused at 0:00, then your closure is called

Set the mode​

Set liveToVodTransitionMode before creating the player: DIVA Player reads it from the configuration it's created with. You can pass it to the initializer or set the property.

var config = DivaConfiguration(
settings: settings,
dictionary: dictionary,
videoId: videoId,
videoMetadataProvider: ExampleVideoMetadataProvider(),
liveToVodTransitionMode: .restartFromZero
)

// or, before creating Diva:
config.liveToVodTransitionMode = .restartFromZero

Handle the transition in your app (custom notifier)​

With .customNotifier, the VOD loads paused and DIVA Player calls your closure once, on the main actor. context.metadata is the VideoMetadata of the finalized VOD (videoId, title, trimIn, trimOut, …).

The closure is a notification only: DIVA Player doesn't wait for it. To resume or restart playback, send player commands through api.

warning

The configuration stores the closure. Capture self (or the player) weakly, otherwise you create a retain cycle.

config.liveToVodTransitionMode = .customNotifier { [weak self] context in
// Main actor. The VOD is loaded and paused.
self?.showEventFinished(videoId: context.metadata.videoId, title: context.metadata.title)
}

// From your UI:
func playFromStart() async {
await diva?.api.sendPlayerCommand(.seek(value: 0)) // milliseconds
await diva?.api.sendPlayerCommand(.play)
}

func resume() async {
await diva?.api.sendPlayerCommand(.play)
}

Player commands are ignored while the player isn't ready, during an ad, in highlights mode, on an error screen, or in the modal player.

Things to know​

  • Default behavior: if you don't set liveToVodTransitionMode, the default .endOfPlay keeps the previous behavior, with one exception on tvOS: when the trim-out cuts the viewer's position, End of Play now shows right away (as on iOS) instead of the VOD starting from the beginning of the stream. To restart the VOD from 0:00 instead, set .restartFromZero.
  • Same source: the setting applies when the finalized VOD has a new source (the usual case). If the source doesn't change, nothing reloads and the setting isn't applied.
  • Modal player (iOS): follows your setting, except .customNotifier, which falls back to .restartFromZero because your app has no reference to the modal player. The modal has no End of Play screen: with .endOfPlay it closes and the main video comes back.
  • Multi-video (iOS): every tile follows your setting. DivaMultivideo exposes no player commands, so with .customNotifier a tile stays paused until the viewer acts on it. Tiles have no End of Play screen: with .endOfPlay a tile goes back to 0:00 and pauses.
  • Chromecast and AirPlay: with .customNotifier the VOD can play for 1–2 s before it pauses.
Known limitations in 5.12.6
  • With .customNotifier, DIVA Player doesn't wait for an ad to end before calling the closure.
  • iOS: after a background/foreground cycle at the transition, the VOD may resume instead of staying paused.
  • iOS: if the event is finalized while the app is in the background and backgroundDurationThreshold isn't set, .restartFromZero and .customNotifier aren't applied and the VOD opens at the old live position.
  • iOS, .endOfPlay at the live edge: End of Play and its countdown can start a few seconds before the VOD ends.
  • iOS, .endOfPlay with the position cut by the trim-out: End of Play shows right away, but up to about 10 s of the VOD can play under it.
  • iOS Chromecast: restarting a VOD with a trim-in starts at the beginning of the source, before the trim-in (as for any trimmed VOD on Chromecast).
tip

To debug the transition, filter the DIVA Player logs by the [Diva][LiveToVOD] prefix.