trannamtrung1st / elFinder.Net.Core

An elFinder backend connector with less magic code and more compatibility. This enables .NET Standard 2.0 projects to easily integrate elFinder functionalities.
Apache License 2.0
12 stars 8 forks source link

Customize path for preview non regular video file #39

Closed benny-adiwijaya closed 2 years ago

benny-adiwijaya commented 2 years ago

Hi, is there a way to customize path for preview non regular video file so the preview is not play the original file?

I can do it with regular video file like mp4 by simply change path in GetFile action. But with non regular video file like AVI or MXF need extra work.

this.support = {
            audio: {
                ogg: support('audio/ogg;'),
                webm: support('audio/webm;'),
                mp3: support('audio/mpeg;'),
                wav: support('audio/wav;'),
                m4a: support('audio/mp4;') || support('audio/x-m4a;') || support('audio/aac;'),
                flac: support('audio/flac;'),
                amr: support('audio/amr;')
            },
            video: {
                ogg: support('video/ogg;'),
                webm: support('video/webm;'),
                mp4: support('video/mp4;'),
                avi: support('video/mp4;'), // added
                mxf: support('video/mp4;'),
                mkv: support('video/x-matroska;') || support('video/webm;'),
                '3gp': support('video/3gpp;') || support('video/mp4;'), // try as mp4
                m3u8: support('application/x-mpegURL', 'video') || support('application/vnd.apple.mpegURL', 'video'),
                mpd: support('application/dash+xml', 'video')
            }
        };
mimes = {
                    'video/mp4': 'mp4',
                    'video/mp4': 'avi',
                    'video/mp4': 'mxf',
                    'video/x-m4v': 'mp4',
                    'video/quicktime': 'mp4',
                    'video/mpeg': 'mpeg',
                    'video/ogg': 'ogg',
                    'application/ogg': 'ogg',
                    'video/webm': 'webm',
                    'video/x-matroska': 'mkv',
                    'video/3gpp': '3gp',
                    'application/vnd.apple.mpegurl': 'm3u8',
                    'application/x-mpegurl': 'm3u8',
                    'application/dash+xml': 'mpd',
                    'video/x-flv': 'flv',
                    'video/x-msvideo': 'avi',
                    'application/mxf': 'mxf'
                },

By adding avi: support('video/mp4;'), and 'video/mp4': 'avi', somehow it works with AVI file, but it dont work with MXF files as it wont open video preview.

PS. The new path I use is mp4 file so it can be played with browser

trannamtrung1st commented 2 years ago

What is the support function here? and the mimes map? it looks strange to me. And eventually, you want to play an MXF video when opening a file in elFinder UI right?

benny-adiwijaya commented 2 years ago

Its override from elfinder.full.js section command "quicklook".

Yes, I want to play MXF file, but because browser impossible to play MXF file I need to change path to play other file like MP4. So, when I open MXF file its playing video from other file. I try to do this by change path in GetFile action in FilesController. Is there another way to do this like change path preview file from JS? Or allow MXF file to act like video file, when click preview its show video player instead of just info file and then redirect to play some MP4 file

benny-adiwijaya commented 2 years ago

https://github.com/Studio-42/elFinder/issues/2656 in this topic says if files have a specific MIME type, it is possible to modify the quicklook command by extending the quicklook plugin. Is it also possible to do this in this project? In my case I want to change quicklook command for MXF just like MP4 so it will open video player and access GetFile action in FilesController

benny-adiwijaya commented 2 years ago

I finally did it by change on elFinder.commands.quicklook HTML5 video preview plugin to force any video file to play as mp4. From

if (mimes[mime] && ql.dispInlineRegex.test(file.mime){

To

if (mimes[mime] && ql.dispInlineRegex.test('video/mp4'){

I dont know if this the best way. But in my case right now this is work

trannamtrung1st commented 2 years ago

Glad to hear that. Otherwise, you may be able to override the PhysicalFileProvider in ASP.NET Core but it's out of scope for this project I think.