markhuge MH\n s

Queue Media in Mpv From Surf

published:

signed with 0x683A22F9469CA4EB

tags:

Surf has an external media player function called clickexternplayer. This function invokes a macro called VIDEOPLAY that’s defined in the config.def.h file.

Here, I’ve edited the macro to use the mmq script from this post:

/* VIDEOPLAY(URI) */
#define VIDEOPLAY(u) {\
        .v = (const char *[]){ "/bin/sh", "-c", \
             "mmq \"$0\"", u, NULL \
        } \
}

By default this function is only called when you click on media with the OnMedia target in the button definitions. In this case I added a handler to send a link to the mpv queue when I Shift+click:

/* button definitions */
/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
static Button buttons[] = {
	/* target       event mask      button  function        argument        stop event */
	{ OnLink,       GDK_SHIFT_MASK, 1,      clickexternplayer, { 0 },       1 },

This is super handy for sites like YouTube, because I don’t need to go to each individual video page to queue the content. I can just shift click as I go through the feeds, and the videos are added to my playlist.

It also allows me to queue videos from multiple sources, YouTube, Vimeo, Twitch, etc. on the same playlist.

About the Author

Mark Wilkerson

0x683A22F9469CA4EB

R&D engineer @ Twitch. Previously Blizzard, Hightail, Co-Founder @ SpeakUp

Mark is building open source tools to make web3 and decentralized self-ownership easy for regular people.

Live dev streams at Twitch.tv

More Posts