Usage
iOS
11.0+ (FairPlay
requires iOS
10.0+)
Swift
5.0+
Xcode
10.2+
Framework dependencies
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding iOSClientExposureDownload
as a dependency is as easy as adding it to the dependencies value of your Package.swift.
dependencies: [
.package(url: "https://github.com/EricssonBroadcastServices/iOSClientExposureDownload", from: "3.1.0")
]
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate iOSClientExposureDownload
into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'iOSClientExposureDownload', '~> 3.1.0'
Carthage is a decentralized dependency manager that builds your dependency graph without interfering with your Xcode
project setup. CI
integration through fastlane is also available.
Install Carthage through Homebrew by performing the following commands:
$ brew update
$ brew install carthage
Once Carthage has been installed, you need to create a Cartfile
which specifies your dependencies. Please consult the artifacts documentation for in-depth information about Cartfile
s and the other artifacts created by Carthage.
github "EricssonBroadcastServices/iOSClientExposureDownload"
Running carthage update
will fetch your dependencies and place them in /Carthage/Checkouts
. You either build the .framework
s and drag them in your Xcode
or attach the fetched projects to your Xcode workspace
.
Finally, make sure you add the .framework
s to your targets General -> Embedded Binaries section.
Client applications can use the ExpoureDownload
by confirming EnigmaDownloadManager
to any class
class MyTestViewController: UIViewController, EnigmaDownloadManager {
// After confirming client applications can use `enigmaDownloadManager` instance to perform any download related tasks.
}
All assets might not be downloadable even if a customer supports download. There can be restriction of blocking downloads for a specific user.
ExposureDownload
provides an API (isAvailableToDownload()
) to check if an Asset
is available to download.
Then client applications can perform the download check by passing the assetId
& the sessionToken
.
enigmaDownloadManager.isAvailableToDownload(assetId: assetId, environment: environment, sessionToken: SessionToken ) { _ in
// Handle Response ( true / false )
}
When a user select an actually downloadable asset ExposureDownload
provides an option to check what can be downloadable for that asset. ( audios
, videos
, subtitles
)
enigmaDownloadManager.getDownloadableInfo(assetId: assetId, environment: environment, sessionToken: session) { downloadInfo in
/// Handle Response
/// downloadInfo.audios , downloadInfo.videos, downloadInfo.subtitles
}
To download an Asset
client applications can create a downloadTask
by passing the assetId
. Task can be prepare
& resume
to start downloading the asset.
task.suspend()
will temporary suspend the downloading task. Suspended task can be resume
.
task.cancel()
will cancel the task.
let task = enigmaDownloadManager.download(assetId: assetId, using: session, in: environment)
task.prepare()
task.resume()
task.suspend()
task.cancel()
downloadTask
publishes several events that the client applications can listen to.
task.onPrepared { _ in
print("📱 Media Download prepared ")
// task.resume()
}
.onCanceled { task, url in
print("📱 Media Download canceled",task.configuration.identifier,url)
}
.onSuspended { _ in
print("📱 Media Download Suspended")
}
.onResumed { _ in
print("📱 Media Download Resumed")
}
.onProgress { _, progress in
print("📱 Percent", progress.current*100,"%")
}
.onError {_, url, error in
print("📱 Download error: \(error)")
}
.onCompleted { _, url in
print("📱 Download completed: \(url)")
}
To download Additional Media such as audios & subtitles client applications can use the same downloadTask
.
task.addAllAdditionalMedia() // will download all aditional media
// .addAudios(hlsNames: ["French", "German"])
// .addSubtitles(hlsNames: ["French"])
Client applications can use enigmaDownloadManager
check if the license for a download asset has expired by passing the assetId
enigmaDownloadManager.isExpired(assetId: asset.assetId) // true / false
If the license has expired , you need to use the downloadTask
to refresh the licenses.
task.refreshLicence()
task.onError {_, url, error in
print("📱 RefreshLicence Task failed with an error: \(error)",url ?? "")
}
.onCompleted { _, url in
print("📱 RefreshLicence Task completed: \(url)")
}
Client applications can get an offlineMediaAsset
( downloaded asset ) by using the EnigmaDownloadManager
.
let downloadedAsset = enigmaDownloadManager.getDownloadedAsset(assetId: assetId)
Or client applications can get AllDownloadedAssets
by using getDownloadedAssets()
let allDownloadedAssets = enigmaDownloadManager.getDownloadedAssets()
Then developers can create a OfflineMediaPlayable
& pass it to the player to play any downloaded asset.
let downloadedAsset = enigmaDownloadManager.getDownloadedAsset(assetId: assetId)
if let entitlement = downloadedAsset?.entitlement, let urlAsset = downloadedAsset?.urlAsset {
let offlineMediaPlayable = OfflineMediaPlayable(assetId: assetId, entitlement: entitlement, url: urlAsset.url)
// Play downloaded asset
player.startPlayback(offlineMediaPlayable: offlineMediaPlayable)
}
To delete a downloaded asset, developer can use removeDownloadedAsset(assetId:)
let _ = enigmaDownloadManager.removeDownloadedAsset(assetId: assetId)
SDK provides an out of the box implementation for downloading FairPlay protected assets. Client applications can create a downloadTask
& start downloading. SDK will download the relevent FairPlay licences & keys and will use them when you are trying to play a FairPlay protected downloaded asset using [ExposurePlayBack
]
Release specific changes can be found in the CHANGELOG.
The procedure to apply when upgrading from one version to another depends on what solution your client application has chosen to integrate Exposure
.
Major changes between releases will be documented with special Upgrade Guides.
Updating your dependencies is done by running carthage update
with the relevant options, such as --use-submodules
, depending on your project setup. For more information regarding dependency management with Carthage
please consult their documentation or run carthage help
.
No formalised roadmap has yet been established but an extensive backlog of possible items exist. The following represent an unordered wish list and is subject to change.
link |
Stars: 0 |
Last commit: 3 weeks ago |
isAvailableToDownload
api has changed & now it takes sessionToken
as a parameterSwiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics