scottjad / player-mode

Conkeror page-mode for controlling media players

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Player-mode

Conkeror page-mode for controlling media players on websites like Youtube, Grooveshark, etc.

Overview

These are the provided commands and their bindings:

CommandKey
playC-c C-return
muteC-c C-m
previousC-c C-p
nextC-c C-n
fullscreenC-c C-f

Supported sites

Site/FeaturePlayPauseNextPreviousMuteUnmuteFullscreen
8tracksXXX-XXN/A
Amazon MP3 StoreXX----N/A
Amazon CloudPlayerXXXXXXN/A
BandcampXXXX--N/A
Hype MachineXXXXXXN/A
Google MusicXXXXNWNWN/A
GroovesharkXXXXXXN/A
Indie ShuffleXXX---N/A
JamendoXXXXNWNWN/A
Last.fmXXX-NWNWN/A
PandoraXXX-XNWN/A
rdioXXXXXXN/A
songzaXXX-XXN/A
SoundCloudXXXXXXN/A
SpotifyXXXXNWNWN/A
Twitter MusicXXX---N/A
Youtube HTML5XXXXXXX

Key

XWorks
NWNot Working/Needs Work
N/ANot Applicable
-Not Supported by Site

Would like to support

  • Amazon Instant Video
  • Netflix

Installation

cd ~/.conkerorrc
git clone https://github.com/scottjad/player-mode.git
ln -s player-mode/player.js .

How to add additional sites

Add something like this to your Conkeror RC file:

def_player_site("grooveshark",
                build_url_regexp($domain = "grooveshark", $allow_www = true),
                {"play": "#play-pause",
                 "mute": "#volume",
                 "previous": "#play-prev",
                 "next": "#play-next"});

If you’re adding support for a popular site, please consider adding it to player.js and creating a pull request once you’ve tested it extensively.

You might want to use something like this to find the the selectors.

require("dom-inspector");
define_key(default_global_keymap, "C-c i", "inspect-click");

How to add additional commands

Say you like to give songs the thumbs down on Pandora. You could add support like this:

player_button_selectors["pandora"]["thumbs-down"] = ".thumbsDownButton";

interactive("player-thumbs-down",
            "Click the thumbs down button.",
            player_command("thumbs-down",
                           "No thumbs down button found"));

define_key(player_keymap, "C-c C-d", "player-thumbs-down");

Or for a like button on Spotify:

player_button_selectors["spotify"]["like"] = player_iframe_button("#app-player","#track-add:not(.added)");

interactive("player-like",
            "Click the like button.",
            player_command("like",
                           "No like button found"));

define_key(player_keymap, "C-c C-u", "player-like");

Controlling your player from your window manager

You could bind a key in your window manager to run a command like this:

conkeror -f player-play

This will first try to interact with the current buffer, but if player-mode is not supported there, then it will interact with the last buffer where player-mode commands were used, if that buffer has not changed to a new document.

Interacting with the last used buffer

To interact with the same buffer that player last used, if it is no longer the current buffer, you would use:

conkeror -f player-last -f player-play

To do this from within conkeror on a buffer that is in player-mode, you can use C-c C-l then a normal player command keybinding like C-c C-n.

There’s currently no way to control the last used buffer from within Conkeror if the current buffer is not in player-mode. I use my window manager bindings in that scenario.

Limitations

  • Does not handle players whose controls are Flash not HTML. If the site uses Flash to play the media itself that’s fine.
  • Currently no way to turn page-modes on by something other than url. So Youtube players on blogs won’t work unless player-mode is enabled manually. And right now even if it is enabled manually it won’t be able to find the player because that’s done by url. There should be a fix for this.
  • Currently no way to have two different players on one page, such as a blog where one article has a youtube player and a soundcloud player.
  • Should eventually support the browser’s built-in HTML5 media player itself. Maybe work up from the currently focused element to find a media player to use, and failing that use the url.

Similar programs

License

MIT/X11

About

Conkeror page-mode for controlling media players

License:MIT License


Languages

Language:JavaScript 100.0%