Skip to content

Instantly share code, notes, and snippets.

@zonble
Created October 2, 2020 17:44
Show Gist options
  • Save zonble/bc79b47086bc05a6425e56fc71f52707 to your computer and use it in GitHub Desktop.
Save zonble/bc79b47086bc05a6425e56fc71f52707 to your computer and use it in GitHub Desktop.
let begin = request.hasByteRaange ? request.byteRange.lowerBound : 0
let end = request.hasByteRaange ? request.byteRange.higherBound : clipFileSize
var readHead = begin
let response = GCDWebServerStreamedResponse(contentType: "video/mp4", asyncStreamBlock: { block in
if readHead < end {
let data = getData(readHead, chunkSize)
block(data, nil)
readHead += data.count
} else {
block(nil, nil)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment