I use Apache2’s mod-autoindex
to build a directory listing of files in a folder and MS Edge to display the list. When I click on a .mp4
file, Edge opens a video player embedded in the browser and correctly plays the video. When I click on a .ts
file, Edge again opens the embedded player, but nothing plays. I have installed the MPEG-2 Video Extension
app from the MS Store and Windows’ built-in Movies and TV
app now successfully plays both .mp4
and .ts
files when I select them from within Windows Explorer. But Edge still can’t play the .ts
file.
The html generated when I click the .ts
file includes the element <source src="https://my.site/foldername/filename.ts" type="video/mp2t">
I conclude that whatever player is invoked by Edge doesn’t know how to deal with the video/mp2t
file type.
Can anyone help me find a way to either (1) change the way Apache2 generates the html to specify type="video/.ts"
or (2) cause the file click to invoke an external player such as Windows’ Movies and TV app rather than Edge’s embedded player?
Since my OP in August, I discovered and implemented a somewhat complex, but perfectly functional way to do what I wanted to do. Herewith, a summary of what I did:
Tiring of the limitations of Apache2’s mod_autoindex
, I developed my own custom index.php
to replace it. Once I had full control over the format and content of the index, I discovered this SO thread wherein @Jun Hsieh
provides a detailed discussion of this former MSDN link, which describes the process for Registering an Application to a URI Scheme.
I followed those instructions to create a custom URI handler that will invoke a DOS batch script on my client. Then I coded my index.php
to create an HTML anchor with an HREF
that invokes my custom URI, including the path to the desired file. When the link is clicked, the browser invokes the URI handler, which invokes the DOS batch script, which validates the file name and proceeds to invoke Microsoft’s MediaPlayer, which includes a codec that can play a network-resident Transport Stream (.ts) file directly, without requiring it to be fully downloaded to the client. The MediaPlayer also has user controls superior to those available in the video player embedded in the Edge browser.
Of course, the custom URI handler is not limited to invoking Microsoft's MediaPlayer and could invoke any app installed on my client PC.
Note that the browser (in this case Edge) will percent-encode the file name passed to the URI handler (i.e. spaces are converted to %20, etc.) so file/folder names that include ‘special’ characters (such as almost every non-letter/number) must be decoded upon receipt to remove the encoding before passing them to the desired app. File/folder names that include characters such as semi-colon, single-quote, and similar characters (perfectly legal in Windows file names) are particularly problematic and must be appropriately handled by the app invoked by the custom URI handler.
Of course, my solution works only on a Windows client, which is OK for me now because I currently do not have any Linux clients on my home network. But believe that it may be possible to create custom handlers on Linux clients as described in this post.
Yes, I’m aware of the potential security risks of this implementation. But my web server serves only the local network within my home. And it now allows me to use a browser as the single UI to browse and stream web content as well as local content. Just what I had been trying to do. Perhaps others will find this information of interest.