Make m3u8 parse and video download as white magic.
Features |
---|
Parse and download m3u8 files |
Customize downloading progress |
Pure Swift |
To run the example project, clone the repo, and run pod install
from the Example directory first.
- Xcode 8.0+
- iOS 9.0+
- Swift 3.0+
Note:
- Your m3u8 file should include #EXFINT information to make parsing pass.
- Your local server's port should be 8080 to make local video play.
Define dowloading directory name:
let directoryName = "Name"
let lemonDeer = LemonDeer()
lemonDeer.directoryName = directoryName
Parse and begin downloading m3u8 with URL:
let directoryName = "Name"
let lemonDeer = LemonDeer()
lemonDeer.directoryName = directoryName
let url = "https://urlstring.m3u8"
lemonDeer.m3u8URL = url
lemonDeer.parse()
Manipulate downloading process:
- Pause
lemonDeer.downloader.pauseDownloadSegment()
- Resume
lemonDeer.downloader.resumeDownloadSegment()
- Cancel
lemonDeer.downloader.cancelDownloadSegment()
Delete downloaded contents
- Delete a specific directory
lemonDeer.downloader.deleteDownloadedContents(with: ("DirectoryNameYouWantToDelete")
- Delete all downloaded contents
lemonDeer.downloader.deleteAllDownloadedContents()
Define your own after download succeeded
class YourClass: LemonDeerDelegate {
func videoDownloadSucceeded()
}
Define your own after download failed
class YourClass: LemonDeerDelegate {
func videoDownloadFailed()
}
Customize downloading progress
class YourClass: LemonDeerDelegate {
func update(_ progress: Float, with directoryName: String) {}
}
LemonDeer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LemonDeer"
Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.
To install with carthage, follow the instruction on Carthage
github "hipposan/LemonDeer"
The Swift Package Manager is a tool for managing the distribution of Swift code. Just add the url of this repo to your Package.swift
file as a dependency:
import PackageDescription
let package = Package(
name: "YourPackage",
dependencies: [
.Package(url: "https://github.com/hipposan/LemonDeer.git", majorVersion: 1.0.0)
]
)
Contact me at Twitter.
LemonDeer is available under the MIT license. See the LICENSE file for more info.