drogon
drogon copied to clipboard
How to allow seeking of download video file ?
I am serving mp4 video files from Drogon like this :
drogon::app().registerHandler(
"/static/{1}",
[](const drogon::HttpRequestPtr &req,
std::function<void(const drogon::HttpResponsePtr &)> &&cb,
std::string fileName) {
auto filePath = "./" + fileName;
auto resp = drogon::HttpResponse::newFileResponse(filePath);
cb(resp);
});
The problem is I cannot seek forward or backward (except for the very beginning) of the video file. If I want to fast forward to 30 seconds I need to wait that the video plays.
Drogon supports range responses, you can try it:
static HttpResponsePtr newFileResponse(
const std::string &fullPath,
size_t offset,
size_t length,
bool setContentRange = true,
const std::string &attachmentFileName = "",
ContentType type = CT_NONE,
const std::string &typeString = "",
const HttpRequestPtr &req = HttpRequestPtr());