iOS SDK migrate v2 to v3 for offlineManager

Product

Player

Question

    if offlineManager.isPlayableOffline(sourceItem: sourceItem),
        let offlineSourceItem = offlineManager.createOfflineSourceItem(for: sourceItem, restrictedToAssetCache: true) {
        sourceItem = offlineSourceItem
    }

Hi @dev3,

Please include a short description of the issue you are observing. This helps us to help you.

I assume you are looking for the new v3 APIs around the OfflineManager/OfflineContentManager?

The old OfflineManager APIs where deprecated in 3.10.0 and finally removed in 3.39.0.

Since this was no v2 → v3 change, this is unfortunately not included in the migration guide. Sorry for the inconvenience.

Anyway, the new API for the code snipped you shared would be the following:

let offlineContentManager = OfflineManager.offlineContentManager(for: sourceConfig)
if offlineContentManager.offlineState == .downloaded {
    let offlineSourceConfig = offlineContentManager.createOfflineSourceConfig(restrictedToAssetCache: true)
    ...
}

Hope that helps.

Hi,David @davidsteinacher
So the OfflineManager has been replaced by OfflineContentManager?
And do you have some demo for OfflineContentManager? Thx.

Adam

Yes, the OfflineContentManager replaced the old OfflineManager APIs, but from a conceptual perspective, everything stayed the same.

Previously, every method of the OfflineManager required to pass in a SourceConfig (SourceItem in v2). This SourceConfig acted more as an identifier than being needed. Therefore we made the switch (also to align with our Android SDK) to the OfflineContentManager, which can be obtained via the OfflineManager and can be used to ‘manage’ the offline content for a given Source (SourceConfig) without the need going through the OfflineManager with the correct SourceConfig all the time anymore.

Documentation references:

Hi David @davidsteinacher ,
I’m also wondering GoogleCasting will be in V3.
Cause I’m curious the v3 in demo just one row code
{
// Initialize ChromeCast support for this application
BitmovinCastManager.initializeCasting()
}

And this is my old version code below,
{
// Add Google Cast
config.remoteControlConfiguration.prepareSource = { [weak self]
(type: BMPRemoteControlType, sourceItem: SourceItem?) in

        switch type {
        case .cast:
            guard let googleCastStreamUrl = self?.video?.dashURL else {
              return nil
            }
            // Create DASHSource as a DASH stream is used for casting
            let dashSource = DASHSource(url: googleCastStreamUrl)

            let castSource = SourceItem(dashSource: dashSource)
            castSource.itemTitle = sourceItem?.itemTitle
            castSource.itemDescription = sourceItem?.itemDescription

            let widevineConfig = WidevineConfiguration(license: licenseUrl)
            
            if needDRM == true{
                widevineConfig.licenseRequestHeaders = ["X-Custom-Data": "token_type=upfront&token_value=\(self?.video?.kks_playback_token ?? "")"]
            }
            
            castSource.add(drmConfiguration: widevineConfig)

            return castSource
        @unknown default:
            return nil
        }
    }

}

Yes, of course, this is still possible in v3.

Please refer to the AdvancedCastingSample where exactly this use-case is showcased in lines 74 to 95. The main difference is the Source initialization which changed from SourceItem(dashSource: dashSource) to SourceConfig(url: dashSource, type: .dash).