Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to allow seeking of download video file ? #2261

Open
Rz-Rz opened this issue Feb 19, 2025 · 1 comment
Open

How to allow seeking of download video file ? #2261

Rz-Rz opened this issue Feb 19, 2025 · 1 comment

Comments

@Rz-Rz
Copy link

Rz-Rz commented Feb 19, 2025

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.

@an-tao
Copy link
Member

an-tao commented Feb 20, 2025

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());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants