FreeTubeApp / FreeTube

An Open Source YouTube app for privacy
https://freetubeapp.io/
GNU Affero General Public License v3.0
13.28k stars 826 forks source link

Open video in external player #418

Closed n1trux closed 3 years ago

n1trux commented 4 years ago

It would be awesome if you could have a setting and a right-click menu entry where you open a video in an external player from a list of videos.

MPV can play youtube (and other!) videos with youtube-dl.

dojima commented 4 years ago

This is probably my most desired feature. Having the option to have FreeTube simply pass the YouTube URL to a configured player when clicking a video thumbnail would be amazing.

pirate486743186 commented 4 years ago

yep, that.

PeterAlabaster commented 4 years ago

Until this gets implemented on freetube - my workaround on linux is click the drawer icon, click Copy YouTube Link, then have a keybind preset for the following: mpv "$(xclip -o -selection clipboard)"

This is basically the same as typing mpv <youtube_url> which MPV auto recognises and plays.

Requirement on debian based distro: sudo apt install xclip

Then just press the keybind combo and video opens in external player

Swap mpv out for whatever player you want (of course it has to support a url in the commandline arg, but each player may have different syntax for this).

I've noticed lately this command errors on some videos, mpv uses youtube-dl and it doesn't seem to recognise video formats. Could be youtube using vp9/h.265? Not sure.

vensko commented 4 years ago

More use cases:

trostboot commented 3 years ago

I'll add my voice of support for a feature like this. Ideally it would be configurable to pass the applicable URL to the external application of choice with a single click on the video.

I'll spare you the details, but this would be a huge improvement for me and I would love to see this implemented.

palikacska commented 3 years ago

Another reason why this feature is a must have: https://github.com/FreeTubeApp/FreeTube/issues/912

felikcat commented 3 years ago

This feature is great if you use filters in your media player to make videos look higher resolution than they are, like MPC-HC + madVR.

feynmania commented 3 years ago

Hi guys! Just discovered FreeTube and I love it! I prefer playing videos in mpv though so I downloaded the source code and edited it so that if I middle-mouse click a thumbnail or video title I open it in mpv. I've never used js before so my implementation is very very ugly but it works so if anyone else is interested I thought I'd post it: All I did was open FreeTube/src/renderer/components/ft-list-video/ft-list-video.js and add the following function to the methods:

activateMiddleMouseClickShortcut: function() {
  // I loop through all the links on the page and change
  // their middle-click function. Doing the entire for loop 
  // seems very silly to me but for some reason I couldn't 
  // get the function to work without it.
  let links_on_page = document.getElementsByClassName('ft-list-video');
  for(let i=0; i<links_on_page.length; i++) {
    links_on_page[i].onauxclick = (e,t) => {
      let youtube_id = ''
      // If we clicked on a title target.src will be undefined 
      // and we retrieve the ID from target.href
      if (e.target.src == undefined) {
        let url_split = e.target.href.split('/')
        youtube_id = url_split[url_split.length - 1]
      }
      // If we clicked on a thumbnail we retrieve
      // the ID from target.src
      else {
        let url_split = e.target.src.split('/')
        youtube_id = url_split[url_split.length - 2]
      }
      let youtube_url = `https://www.youtube.com/watch?v=${youtube_id}`
      let child = cp.spawn('mpv', [youtube_url], { detached: true, stdio: 'ignore' });
      child.unref();
      return false;
      }
  }
},

and then run this new function in the mounted() function (right above "methods:"), so I changed the mounted function to:

mounted: function () {
  this.parseVideoData()
  this.checkIfWatched()
  this.activateMiddleMouseClickShortcut()
},

Finally just add

import cp from "child_process"

to the top since I use that in activateMiddleMouseClickShortcut to run mpv. Of course you could change mpv here to whatever you like.

Generator commented 3 years ago

@feynmania create a pull request so de dev can implement

no-realm commented 3 years ago

EDIT 4: PR #1271

no-realm commented 3 years ago

Working on a proper PR...

sith-on-mars commented 3 years ago

It's awesome that the support for external video player is finally included in 0.14!

Would it be possible to enable custom external video player? Or is there any current workaround? I'm using Celluloid which is a mpv GUI frontend. It seems changing neither "Custom External Player Executable" nor "Custom External Player Arguments" in settings worked if I wanted to use Celluloid instead of mpv.

no-realm commented 3 years ago

It's awesome that the support for external video player is finally included in 0.14!

Would it be possible to enable custom external video player? Or is there any current workaround? I'm using Celluloid which is a mpv GUI frontend. It seems changing neither "Custom External Player Executable" nor "Custom External Player Arguments" in settings worked if I wanted to use Celluloid instead of mpv.

@sith-on-mars If you are interested in adding support for an external player, feel free to take a look at: #1409 / #1424

dojima commented 3 years ago

Why not just add a 'Custom' setting where people can enter the path of their video player and their own external arguments with a variable representing the YouTube URL.

no-realm commented 3 years ago

Why not just add a 'Custom' setting where people can enter the path of their video player and their own external arguments with a variable representing the YouTube URL.

Because that would have been too complicated for most users, which is why it wasn't included in the initial implementation of this feature. That being said, I personally think that this would be a neat addition, so if someone wants to volunteer, and submit a PR for this, feel free to do so :smile:

no-realm commented 3 years ago

@sith-on-mars Also, I just took a look at Celluloid, and the reason why it doesn't work with the current mpv flags can be seen here:

It is also possible to set mpv options by putting the options — as you would pass to mpv on the command line — in Extra MPV Options text box in the preferences dialog. You can also pass options directly on the command line by adding mpv- prefix to the option name. For example, using the option --mpv-vf=flip when launching Celluloid is equivalent to using --vf=flip in mpv.

So, theoretically, a PR for adding Celluloid support would need to make the following changes/additions (NOT TESTED):

    {
        "name": "Celluloid",
        "value": "celluloid",
        "cmdArguments": {
            "defaultExecutable": "celluloid",
            "supportsYtdlProtocol": true,
            "videoUrl": "",
            "playlistUrl": "",
            "startOffset": "--mpv-start=",
            "playbackRate": "--mpv-speed=",
            "playlistIndex": "--mpv-playlist-start=",
            "playlistReverse": null,
            "playlistShuffle": "--mpv-shuffle",
            "playlistLoop": "--mpv-loop-playlist"
        }
    }

Like you might have noticed, these are almost the exact changes as in PR #1424, minus the defaultCustomArguments part, which I don't know whether it is required for Celluloid :shrug:.