rejetto forum

How to run some html script when clicking on some file

0 Members and 1 Guest are viewing this topic.

Offline easyspot

  • Occasional poster
  • *
    • Posts: 14
    • View Profile
Hi, how to run some html script when clicking on some file instead of handled by the browser itself ?
I mean, the default is: When I put MIME n click on a .mp4 file, then browser will open the file only in the browser.
I need to run .mp4 with subtitle support, but it's not a good idea to put index.html in every folder to do that.
I think maybe something can be done in template file so I can put html codes in there to handle .mp4 files.
Im using 2.4rc7. Thanks before.
« Last Edit: March 31, 2023, 06:22:55 PM by easyspot »


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
Hi, how to run some html script when clicking on some file instead of handled by the browser itself ?
I mean, the default is: When I put MIME n click on a .mp4 file, then browser will open the file only in the browser.
I need to run .mp4 with subtitle support, but it's not a good idea to put index.html in every folder to do that.
I think maybe something can be done in template file so I can put html codes in there to handle .mp4 files.
Im using 2.4rc7. Thanks before.
Hi!, this is complex stuff...

Option A) You need to write a macro to do a 'URL rewrite' (search on the forum about [+request]), but only if end-users are accessing the MP4 directly (this is not the most common situation), but in that case...

For example, you could have these files:
Code: [Select]
https://localhost/files/video123.mp4
https://localhost/files/video456.mp4
https://localhost/player.html

So, every time a .mp4 is requested, using a macro HFS could rewrite the URL to deliver the player HTML with the MP4 file attached on the URL, like this:

Quote
https://localhost/player.html#files/video123.mp4

or

Quote
https://localhost/player.html#files/video456.mp4

Option B) But in case end-users are accessing MP4 files from a file listing, then is much easier, since you only need to modify your template and have some HTML knowledge. You only need to have a single 'player.html' with a JavaScript that 'reads' the video from the URL (search on Google about 'read the URL parameters with JavaScript').

If you could share the minimal HTML code of your video player (player.html), that you used to play .mp4 "with subtitle support" on the browser, then we could think a solution to convert it to some macro (I don't promise anything, since it depends on the complexity of the code). As reference only (and out of curiosity), you could comment what library are you using to play subtitles, perhaps MP4Box.js?). By the way, I don't have any small MP4 with subtitles embedded to make some tests, so, don't expect too much help from me.

» Important detail: latest HFS v2.4 RC7 could PROBABLY have some macros broken, since I've already reported here, so even if you have the correct macro, it could not work (unless you find which older version have this working). Sadly, I didn't have the time to find out a solution to this, neither the reason of why it doesn't work.

That's all I can help for now, I hope it helps! :)

Cheers,
Leo.-

PS: You could edit the title to 'How to do a URL rewrite using macros?' to get more attention to your request.
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.