Skip to content
/ HLSion Public

HTTP Live Streaming (HLS) download manager to offline playback.

License

Notifications You must be signed in to change notification settings

r-plus/HLSion

Repository files navigation

HLSion

Carthage compatible

HTTP Live Streaming (HLS) download manager to offline playback.

Requirements

  • iOS 10.0+
  • Xcode 8.0+
  • Swift 3.0+

Installation

Add below to your Cartfile.

github "r-plus/HLSion" "master"

Thus build framework.

carthage update HLSion

Usage

import HLSion

let url = URL(string: "https://...m3u8")!
let hlsion = HLSion(url: url, name: "identifier").download { (progressPercentage) in
    // call while each file downloaded.
}.finish { (relativePath) in
    // call when complete or cancel download task finish.
}.onError { (error) in
    // call when error finish.
}

// cancelable.
hlsion.cancelDownload()

// delete downloaded asset.
hlsion.deleteAsset()

Play after download.

guard let localUrl = hlsion.localUrl else {
    // This instance not yet downloaded.
    return
}
let localAsset = AVURLAsset(url: localUrl)
let playerItem = AVPlayerItem(asset: localAsset)
let player = AVPlayer(playerItem: playerItem)
player.play()

About

HTTP Live Streaming (HLS) download manager to offline playback.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published