0

I've an application that allows users to add a video. This video is an MP4 format and saved via a FileField to the model. I want to play the video via a fileResponse (view). This FileResponse plays the video in an html. I would like to customize the tag. But I don't know where to.

Does anyone know how I can add an HTML-template for a FileResponse? Or add attributes for the video-tag via the view ?

jefferson
  • 105
  • 1
  • 9
  • 1
    Not clear. _" I would however like to customize the tag."_ Is the only thing that made sense in your first paragraph. Which one is more correct here... **(1)** _"I have made an application that serves..."_ or **(2)** _"I have to communicate with an external application that serves..."_ ... What is in the fileResponse (video bytes or html/text bytes)? If you got HTML text for defining a ` – VC.One Jul 24 '22 at 18:09
  • 1
    It is not returned in HTML. It simply sends the binary content of the file. It is possible that the browser will *render* the movie, or pdf, etc. and thus visualize the video. – Willem Van Onsem Jul 24 '22 at 21:41
  • @WillemVanOnsem , understand ... but then I've [another question posted here](https://stackoverflow.com/questions/73154226/how-to-restrict-access-to-a-media-file-in-django) – jefferson Jul 28 '22 at 14:08
  • @jefferson Sorry still not clear. Your other question makes more sense. That one makes it clear that you made the app (have control) but here, in this question, you talk as though app is doing whatever and you have no control over the code like _"This FileResponse plays the video in an html... I never wanted that and I don't know what to do"_ ... Why not just admit _"I can successfully play a video in HTML5 using my code but now I want to replace SRC where instead of URL, I provide a buffer to the video tag"_ (if `fileResponse` is actually containing video bytes). – VC.One Jul 31 '22 at 11:35
  • PS: I don't use Python/Django but in general, to play file bytes in a video tag, you make a request to the file server, they give back the bytes (is your response data as an array), then you use Javascript to `createObjectURL` which turns the bytes array into temporary file path (exists in memory)... You need to find out how a Django variable can be used in your `` tag and then see if the JS ` – VC.One Jul 31 '22 at 11:43
  • PPS: My bad after some research I see Django works like PHP (is server-side operations) that runs before the JS part is initialized by client side (_ie:_ you cant use JS code) ... If what you're trying to do is hide a video URL then just make an HTML page where the video tag's `src` is pointing to a script (Django or PHP) whose job is to return the actual video file (as bytes), the ` – VC.One Jul 31 '22 at 12:03

0 Answers0