adamreichold / QMediathekView

Alternative Qt-based MediathekView front-end
GNU General Public License v3.0
17 stars 5 forks source link

Honor the default video application on Linux #9

Open probonopd opened 5 years ago

probonopd commented 5 years ago

Instead of defaulting to VLC which may or may not be installed on the system, default to the system's default media player which can be queried like this:

me@host:~$ xdg-mime query default video/mp4
parole.desktop
adamreichold commented 5 years ago

The problem is that I pass a URL to this application and I need to be sure that it is able to handle streaming via e.g. HTTP in addition to the video format itself (which might also not be MPEG4).

Also having to start with a desktop file more or less implies that I have to parse that and understand its placeholder syntax to be able to execute the application and pass it that URL. (Well this somewhat answers the above question as I could look for %u instead of %f to determine whether streaming would be possible.) Is this functionality packaged up in the xdg utils somehow?

It might actually be simpler to hard-code a list of useful media players and check until a suitable one is found on the system?

probonopd commented 5 years ago

I think it's OK to query like I do above for mp4 and use that video player as the default for all types of video.

It might actually be simpler to hard-code a list of useful media players and check until a suitable one is found on the system?

No, because there may be many on the system but only one is defined as the default by the user (or distribution).

probonopd commented 5 years ago

Also having to start with a desktop file more or less implies that I have to parse that and understand its placeholder syntax to be able to execute the application and pass it that URL.

Simply find the desktop file, get the content of the Exec= key up to the first blank, and use that. Should work in 99% of time ;-)

I think it's better as a default than hardcoding vlc. Users can still change it.

adamreichold commented 5 years ago

I agree that it is better to be correct 95% of the time than to be wrong albeit in a deterministic manner. So I basically introduced some shell in #12 to implement your above suggestions and fallback to the hard-coded VLC otherwise. Could please give the PR a try?

(And yes, I relented and switch to using uploadtool so there will be a transer.sh link on the PR page. (Running Travis locally is surprisingly complicated compared to GitLab CI. I should probably move this repository there when I have the time as this will simplify these things considerably due to the integrated artifact storage and such...))