Giter Club home page Giter Club logo

keysocket's Introduction

LICENSE Chrome Web Store Chrome Web Store Chrome Web Store github-stars-image

Global keyboard bindings to control your Chrome-based music player. Allows your keyboard media keys (play/pause, next, previous) to work when you're listening to music on various streaming websites.

Supported Sites

  • 163 Music
  • 8tracks
  • Amazon Cloud Player
  • Bandcamp
  • Birp
  • Bop
  • Brain.fm
  • Bugs Music
  • Castbox.fm
  • Chrome Built-In Player
  • Comcast/Xfinity
  • Coursera
  • Crunchyroll
  • Deezer
  • Digitally Imported (di.fm)
  • Gaana.com
  • Google Play Music
  • Groove Music
  • HearThis.at
  • Hype Machine
  • iloveradio.de
  • BBC iPlayer
  • Jamendo
  • Jamstash
  • Jango.com
  • Mixcloud
  • Zing MP3
  • Met Opera Season On-Demand
  • Music Choice (untested)
  • Myspace
  • Myzuka.fm
  • Napster
  • Naxos Music Library
  • Netflix
  • Noisli (only without account tested)
  • Noon Pacific (untested)
  • NRK Radio
  • Ok.ru
  • Openload.co
  • Overcast
  • Pandora
  • Phish Tracks
  • Picarto.tv
  • Plex
  • Pluralsight
  • Pocketcasts.com
  • Qobuz
  • Relax-Hub.com
  • Saavn.com
  • Showmax
  • Sirius XM Radio
  • Slacker
  • SomaFM
  • Soundcloud
  • Sowndhaus
  • Spotify
  • Spreaker
  • Streamsquid
  • Subsonic (and Madsonic)
  • Superplayer.fm (untested)
  • Supersport.com
  • Synology Audio Station v.5 (untested)
  • thesixtyone
  • Tidal (untested)
  • tunein.com
  • tver.jp
  • Twitch.tv
  • Ustream.tv
  • vk.com (Vkontakte)
  • Vimeo
  • XFINITY (untested)
  • Xiami Music
  • YouTube
  • YouTube Music
  • Zvooq
  • Яндекс.Музыка (Yandex.Music)
  • Яндекс.Радио (Yandex.Radio)
  • IbizaSonica.com

Untested Sites (after latest changes)

  • Music Choice (account is needed)
  • Noon Pacific (account is needed)
  • Superplayer.fm (regional restrictions)
  • Synology (special environment is needed)
  • Tidal (regional restrictions)
  • XFINITY (account is needed)

Usage

  1. Install extension from the chrome web store.
  2. Edit the Keyboard shortcuts to give Keysocket 'Global' permissions
    • Open a browser tab to chrome://extensions
    • Scroll to the bottom & click Keyboard shortcuts
    • Find Keysocket Media Keys and change each desired key to Global

API

Keysocket also provides an API that websites can use to bind their players without the need to wait for their PR to be accepted and released in the Chrome Webstore extension. Keysocket fires events for each media key, which the website can add event listeners for. Below is an example from http://www.relax-hub.com, written by the current project maintainer, Feedbee:

// Web Page Media Control API interaction (v0.4)
// https://github.com/feedbee/web-page-media-control-api-spec
// for Key Socket Media Keys Chrome extension
// https://chrome.google.com/webstore/detail/key-socket-media-keys/fphfgdknbpakeedbaenojjdcdoajihik?hl=en

document.addEventListener("MediaPlayPause", function () {
  playerCollection.send("toggle");
});
document.addEventListener("MediaStop", function () {
  playerCollection.send("stop");
});
document.addEventListener("MediaPrev", function () {
  var player = playerCollection.getPrevPlayer();
  if (player) {
      player.send("play");
  }
});
document.addEventListener("MediaNext", function () {
  var player = playerCollection.getNextPlayer();
  if (player) {
      player.send("play");
  }
});

Web Page Media Control API documentation is available here.

Please, contribute!

  • Looking for plugins for other music players. Create Pull Requests to contribute. Create Issues to inform us about broken sites (but PR is preferable).

Plugin creation is simple. If you have found a website with media content, that isn't supported by keysocket, just write a plugin by yourself and create new Pull Request to share it with others. How to do it?

First of all, determine the fixed part of website's URL, where a media content is shown. In extension/manifest.json add an item into content_scripts array like this:

    {
      "matches": ["*://example.com/player*"],
      "js": ["plugin-api.js", "keysocket-example-service-name.js"]
    },

Create new file into extension folder using the pattern keysocket-example-service-name.js (use your service name to replace example-service-name part). Write plugin's code there. Check other plugins for examples.

Typically, plugin can interact with a player using either button press simulation or public API call. The second option implies you writing custom JS code to talk to player, while the first one requires just to mention DOM selectors to configure keysocket.

keySocket.init('example-service-name', {
    "play-pause": '...',
    "prev": '...',
    "next": '...',
    "stop": '...'
});

In the code above two arguments were passed to keySocket.init function. The first argument is a plugin name, it used for logging and can be anything you want. The second argument is a map used to bind keysocket events (which is caused by user pressing control keys) to buttons or code, that handles this event. The events are play-pause, prev, next and stop. Any of them can be omitted in the map.

So, passing a function as an event handler, you set the code, that will be called when event is thrown. Passing anything else, which expected to be a string, you define DOM selector to look up for a DOM object to simulate click on it.

Different websites require different approaches to dial with them. So, make a research to find the best solution in your case. Look through the other plugins (extension/keysocket-*.js files) for the reference.

keysocket's People

Contributors

aliangliang avatar borismus avatar chrisdeely avatar coliff avatar delef avatar emadhajjar avatar ewen-lbh avatar exedk avatar feedbee avatar godofcpu avatar hobeone avatar imduffy15 avatar jdf221 avatar kristianj avatar legionaryu avatar max99x avatar maxgillett avatar medone-nalexander avatar mrpoptart avatar nemchik avatar nolsto avatar perotinus avatar queengooborg avatar rdavidwu avatar rtm516 avatar salfab avatar skinner927 avatar vijay40 avatar vomchik avatar wernight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keysocket's Issues

Update Deezer support

Every button does the task twice. Also, the "previous" button goes to the next song.

cant build app in mac

I am not able to build this on mac. i get the following error:
error: icon file must exist: 'res/icon.icns'
The folder seems to be missing this icon file.

Not locking the media keys in OS X

I'm using Key Socket in OS X 10.8.3 and every time I press the play button iTunes is launched, if I press the previous or next the same action is performed in iTunes.

Permissions too broad when installing

I read through the manifest and it seems like the permissions are specific enough that I would use this extension. However, when I install from the chrome webstore I get a permission prompt that looks like this:

screen shot 2014-08-14 at 10 47 43 am

Media Keys don't function outside of browser

To recreate:
Have Chrome open with extension enabled, not using any streaming service.
Open Spotify desktop client.
Notice that the Media Keys do not function.
Disable KeySocket Extension in Chrome - Media Keys work again in Spotify.

Perhaps KeySocket can unhook the keypress events when there is no site open to receive the keypresses?

Improve documentation

  1. The Chrome web store is the main place to install but it has no documentation and doesn't point to this website.
  2. Merge README Usage and Build sections. Both say the same: You need to Chrome extension and a daemon running on the same machine, with various ways to install the daemon.
  3. Chrome extension install should say that once installed there should be a "Unsafe Script" icon in the URL when going to Google Music, Deezer... and user should click and allow: Chrome Secure
  4. Help users to make daemon run on startup.

Go server can't reconnect

[Ubuntu 14.04 pre]

When I restart chrome and start the Go keyserver from the terminals, it works. If I then restart the keyserver, it still tries to send events but the extension doesn't do anything. Not sure if it can't connect to the extension, there are no errors logged.

Add Bandcamp.com

Bandcamp.com support would be great! I've been reading through their JS for the last hour or so but I haven't been able to tap into it. The most reliable method seems to be just simulating clicks on the play/pause and next/previous elements on the page:

// Click play / pause
document.querySelector('.playbutton').click()

// Click next / previous
document.querySelector('.nextbutton').click()
document.querySelector('. prevbutton').click()

This works fine on album pages (e.g. https://cascaderecords.bandcamp.com/album/1001-nights-ep) but doesn't work well on any other page as .playbutton either doesn't exist or can match more than one element.

PlayPause key does not work.

PlayPause key doensn't work with Jamstash (haven't tried any other clients).

Next/Prev do.

Using Chromium 38.0.2125.111, archlinux 3.17.2-1-ARCH

dbus.exceptions: No such interface `org.gnome.SettingsDaemon.MediaKeys'

When running keysocket.py:

Traceback (most recent call last):
  File "keysocket.py", line 180, in <module>
    main()
  File "keysocket.py", line 162, in main
    factory = BroadcastServerFactory('ws://localhost:1337')
  File "keysocket.py", line 87, in __init__
    self.keys_listener = DBusMediaKeyListener(callback=self._onMediaKeyEvent)
  File "keysocket.py", line 49, in __init__
    self.app, 0, dbus_interface='org.gnome.SettingsDaemon.MediaKeys')
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: No such interface `org.gnome.SettingsDaemon.MediaKeys' on object at path /org/gnome/SettingsDaemon/MediaKeys

Using Awesome tiling manager with Gnome on Ubuntu 12.04.02 LTS.

  • dbus 1.4.18

WebSocket error latest beta version of Chrome (34.0.1847.92 beta-m)

I upgraded to the latest beta build of Chrome today and started seeing this error in the console:

Connecting to a non-secure WebSocket server from a secure origin is deprecated. shared.js:8
keysocket: connecting to WS shared.js:7
Connecting to a non-secure WebSocket server from a secure origin is deprecated. shared.js:8
keysocket: WebSocket Error:
Event {clipboardData: undefined, cancelBubble: false, returnValue: true, srcElement: WebSocket, defaultPrevented: false…}
shared.js:16
keysocket: WS close
CloseEvent {reason: "", code: 1006, wasClean: false, clipboardData: undefined, cancelBubble: false…}

ON/OFF shortcut

I sometimes listen music on the Spotify app that handle the multimedia keys natively and sometimes on Soundcloud for which I use Key Socket.
Key Socket works great for Soundcloud, it prevent multimedia keys to reach Spotify and handle it well.

But it would be great to have the option to setup a shortcut to turn Key Socket ON/OFF like AddblockPlus does for instance, because not the only option is going in the extensions option of chrome and deactivating the extension.

Thanks for this extension!

Amazon's new player doesn't work

I attempted to find a fix and submit but wasn't able to figure it out. One issue for sure is the manifest has an older URL, and after updating this I can see the keys being sent to the console, but they don't seem to have any effect, and I'm not sure why.

Only works sometimes on Tidal Hifi

On Tidal, the plugin seems to work occasionally but does not work for the majority of the time. No response from any hotkeys. It does work fine on youtube, google music, and anything else i tried..

Improve Chrome extension description

The Chrome web store is the main place to install but it lack of documentation and should clearly point to this website.

I didn't find where it's stored. Most important is to add in the description to come here to look for installation procedure.

Spotify web player update not working

Hi, I am trying to use it with the spotify web player that has been update in the latest days. However it seems that it didn't work.
Thank you very much.

Play/Pause not working in Jamstash

Hi there, I'm using Jamstash.com with my personal subsonic server.
The extension is working for the previous and next song button and for what I can tell it's detecting the play/pause button but it's not working.
This is a screenshot of the console after pressing the play/pause button, it's detected but an error occurs: http://puu.sh/gCKVc/ea61e95f81.png

Thanks in advance :)

Pause if there is no Stop

This may be outside of the scope, but would it be possible that when I press the stop button and a website doesnt support the stop functionality that the pause button is pressed in place of stop but only if music is playing?

so i guess the logic would be something like this;
if (music-is-playing = false) stop does nothing, or does it's standard stop input
if (music-is-playing = true) stop button will trigger pause input
from there it can get fancy such as only do this behavior on websites that don't have stop functionality (in my experience most dont have stop) if that's something that needs to happen.

If this is possible, sweet! I'd love to see it happen! If not, drats, thanks for reading, and go ahead and close this.

Keysocket now conflicts with chrome built in media keys support

chrome version 35.0.1916.86 beta-m seems to have support built in for media keys, at least on Google Music site. I have not tested other sites.

Which now conflicts with keysocket as it will trigger the event to the site twice. Once from chrome, and once from keysocket.

Broken for players served over HTTPS (e.g. Google Music)

On Chrome 36 (Linux, but probably doesn't matter), KeySocket is broken by new security limitations:

[blocked] The page at 'https://play.google.com/music/listen?u=1#/all' was loaded over HTTPS, but ran insecure content from 'ws://localhost:1337/': this content should also be loaded over HTTPS.

It's possible that just changing the scheme to "wss" will solve this, but I don't know if all of the server implementations which KeySocket uses automatically support secure connections.

KeySocket.app is localized to smus

I get "11-08-08 11:19:11 AM [0x0-0x1bf1bf].org.pythonmac.unspecified.KeySocket[7578] IOError: [Errno 2] No such file or directory: '/Users/smus/Projects/keysocket/server/keysocket.py'"
in the console window.

Linux support

Dear @borismus,

Thanks a lot for this extension. I was looking for a way to control YouTube using the media keys. I couldn't find any information in the readme whether this extension is OS-specific.

More specifically, does it support Linux?

Thankfully,

Robert

Several opened tabs with music

When user have several opened tabs with supported music sites (i.e he listen to music on music.yandex.ru and have opened vk.com), message sent to all tabs. And when I want to start playing at music.yandex.ru, actually it starts on both sites.

I have few thoughts regarding this problem. We can pass callback as third argument to chrome.tabs.sendMessage in this loop and break it when music tab found. It is simple option. More complex option is control audio events somehow and order tabs by last audio events. I.e. when user starts audio player on music.yandex.ru it becomes more prioritized tab and then we sendMessage only to this tab. What do you think? I'm not sure, can we control audio events on page from extension? Any thoughts?

Yotube Next/Prev not working

Since the last update of the playlist view you must use

'prev-playlist-list-item' and 'next-playlist-list-item'

for the class names.

Youtube key functions requires update!

Hi there,

It was also mentioned in your Chrome extension site at review panel, and I just wanted to remind it in here aswell.

Instead of ytp-button-play it became ytp-play-button and this is true for all other buttons (prev, next..)

I've manually changed those values to test it and I can confirm it works, it just needs an update!

jamstash broken

the element ID for the play / pause buttons are no longer in place. If I add an ID manually to the page using the inspector and change the js as so it works

var connection = null;
var isConnected = false;

function controlJamstash(key) {
if(key === PREV) {
//var prevButton = document.getElementById('PreviousTrack');
var prevButton = document.querySelector('#PreviousTrack');
simulateClick(prevButton);
} else if(key === NEXT) {
var nextButton = document.getElementById('NextTrack');
simulateClick(nextButton);
} else if(key === PLAY) {
var isPlaying = document.querySelector('a.button.PlayTrack').style.display === 'none';
var playPauseButton = null;
if(isPlaying) {
playPauseButton = document.getElementById('TheEffingButton');
//playPauseButton = document.querySelector('a.button.PlayTrack')
} else {
playPauseButton = document.querySelector('.PauseTrack')
//playPauseButton = document.getElementById('PlayTrack');
}
simulateClick(playPauseButton);
}
}

reconnect(controlJamstash, connection, isConnected);

I also tried to adjust this using the querySelector fn to target the buttons by their existing class names something derails there. works by ID, fails by class. I'll dig further but I thought maybe someone might see the issue putting their eyes to this. Also note that the prev/next track buttons (by id with existing ID attributes on the elements) still work.

8tracks Support?

Hi,

I was wondering if it would be possible for you to add support for 8tracks?

Thanks.

Windows Server capturing keystrokes?

Not sure this is the right place to post this.

When running the Windows version of KeySocket, whenever I press an accent key (like ~ or ' ) I get two characters instead of one (~~ instead of ~). This is messing up my ability to type in Portuguese, because the accents cannot be assigned to vowels (~a results in ã).

YouTube API doesn't seem to work

The YT specific functions don't seem to be defined when it uses HTML5 <video>. I tried this instead which works:

if(document.getElementsByTagName('video')[0]) {
    var video = document.getElementsByTagName('video')[0];
    var isVideoPaused = video.paused;
    var playVideo = function() { video.play(); };
    var pauseVideo = function() { video.pause(); };
} else {
    var video = document.getElementById('movie_player');
    var isVideoPaused = (video.getPlayerState() === 2);
    var playVideo = function() { video.playVideo(); };
    var pauseVideo = function() { video.pauseVideo(); };
}

if(isVideoPaused)
    playVideo();
else
    pauseVideo();

Don't use "-A" option with py2app

In the README, it is stated:

python setup.py py2app -A

but this builds an app with " in place " files which is not suitable for distribution.

Lacks support for remote play/pause button on headphones

I can stop/start music on my Synology Audio Station with play/pause key on my mac keyboard, before installing the plugin it just opened iTunes on my computer when pressing the play/pause key, all good. However, it doesn't seem to bind to the play/pause button on my headphones, pressing it still starts iTunes instead of starting/stopping the music.

Synology standalone app window not supported

Works perfectly when full Synology UI is opened (/webman/index.cgi), however if you open just the AudioStation app separately (/audio/index.cgi), the playback isn't controlled.

Google Music Simulate Click not Working

I've installed the python app, and the extension, but the best I can get for a pause is a slight stutter. I think the issue is the simulateClick function, and when I run it in the dev tools' console, it doesn't work. I've worked out a solution that works on my solution (it involves the click() event on the element retrieved from document.querySelector(). I'm not quite sure how to edit the extension to actually run it, so I'm working on that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.