Squeeze back
What you learn​
You're instantiating DIVA Player in your app and relying on DIVA Back Office as the video streaming source.
The goal of this article is to build the simplest front-end to stream a video from the DIVA Back Office with, at the end, the activation of Squeeze Back in combination with End of Play.
Before starting​
- Ensure the DIVA Back Office instance you rely on is up and running.
- Ask your video engineers team
<videoId>
,<settingsURL>
,<languageCountryCode>
,<userToken>
and<sharedKey>
. - Ensure the VideoMetadata contains the squeezeBackTime property.
In portrait mode squeezback will not be shown. But if you have recomendation it will be displayed in the bottom of the screen. End of play screen will appear on the top of the video player when the video ends.
Instantiation​
Write the Basic instantiation code. There's no additional code to write, unless you need to overwrite the queezeBackTime property that the VideoMetadata/Endofplay contains.
Squeeze back configuration​
Modify the below settings in the VideoMetadataManager extension to alter the VideoMetadata as in the following example, and set the squeezeBackTime
property:
0
default value if not set, no squeeze back10000
to set the squeeze back- A positive integer that specifies the number of milliseconds before the end of the video when the Diva Player starts the squeezeback. (eg: with
10000
the squeezeback starts when remain 10 seconds to the video end).
public struct SWBehaviourEndOfPlayCleanModel: Codable, Equatable, Sendable {
/** Squeezeback offset from video end in milliseconds. 0 or negative means disabled. default 10000 */
public var squeezeBackTime: Double
//.....
}
Working sample code for overwriting Squeeze Back data​
Use the VideoMetadataManager extension to overwrite the End of Play data (and any other video metadata). This extension method uses BO adapter to get video metadata and exposes the result which can be altered before it gets passed to Diva Player. Below a sample code.
import DivaBOAdapter
import DivaCore
extension VideoMetadataManager: @retroactive VideoMetadataProvider {
public func requestVideoMetadata(
videoId: String,
currentVideoMetadata: DivaCore.SWVideoMetadataCleanModel?,
playbackState: DivaCore.DivaModel.PlaybackState
) async throws -> DivaCore.SWVideoMetadataCleanModel {
do {
var videoMetadata = try await getVideoMetadata(
videoId: videoId,
isChromecastMode: false,
isAirPlayActive: false
)
// you can modify the videoMetadata struct here
videoMetadata.behaviour.endOfPlay.squeezeBackTime = 120_000
return videoMetadata
} catch let error as DivaModel.VideoMetadataProviderError {
throw error
} catch let error as VideoMetadataManager.VideoMetadataManagerError {
throw DivaModel.VideoMetadataProviderError.other(message: error.description)
} catch {
throw error
}
}
}
Dictionary​
No additional traslations needed.
Analytics events​
Find here the available analytics events for the Squeeze back.