Giter Site home page Giter Site logo

vs-media-player's Introduction

vs-media-player

Latest Release Installs Rating

Visual Studio Code (VSCode) extension to control media players like Spotify or VLC directly from the editor.

Demo 1 Spotify

Donate

Table of contents

  1. Install
  2. How to use

Install []

Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter:

ext install vs-media-player

Or search for things like vs-media-player in your editor:

Start Spotify OAuth

How to use []

Open (or create) a settings.json file in your .vscode subfolder of your workspace or edit your global settings by using CTRL + , shortcut:

Add a media.player section and define one or more players:

{
    "media.player": {
        "players": [
            {
                "name": "My Spotify player",
                "type": "spotify",
            },

            {
                "name": "My VLC player",
                "type": "vlc",
            }
        ]
    }
}

A player entry supports the following, common properties:

Name Description
buttonPriorityOffset A custom offset value for controlling the priority of the buttons in the status bar. Default 10
connectOnStartup Connect on startup or not. Default (true)
defaultOutputID The ID of the default output device. Default 1
defaultOutputName The name of the default output device. Default Main device
description A description for the player.
initialOutput The name of the output device, which should be selected after extension has been connected to the player.
name A (display) name for the player.
showNextButton Show button for playing NEXT track in status bar or not. Default (true)
showPlayerName Show player name in status bar or not. Default (false)
showPrevButton Show button for playing PREVIOUS track in status bar or not. Default (true)
showRight Show buttons on the RIGHT side of status bar or not. Default (false)
showToggleMuteButton Show button for toggle mute state in status bar or not. Default (true)
showTogglePlayButton Show button for toggle play state in status bar or not. Default (true)
showToggleRepeatingButton Show button for toggle repeating state in status bar or not. Default (false)
showToggleShuffleButton Show button for toggle shuffle state in status bar or not. Default (false)
showTrackSelectorButton Show button for selecting a track in status bar or not. Default (true)
showVolumeButtons Show buttons to change volume in status bar or not. Default (false)
type The type.

Spotify []

{
    "media.player": {
        "players": [
            {
                "name": "My Spotify player",
                "type": "spotify"
            }
        ]
    }
}
Feature Supported by spotilocal Supported by Web API
Load playlists   X
Mute volume X
Pause X X
Play X X
Play next track X
Play previous track X
Play track X
Search for playlists X
Search for tracks X
Select output X
Toggle repeating (only state is displayed) X
Toggle shuffle (only state is displayed) X
Volume down X
Volume up X

To extend the basic features provided by spotilocal module, take a look at the Web API section to get to known how to setup the extension for OAuth.

Web API []

First of all, you have to register an app here:

Register app in Spotify

After you have added the app, you need to select and edit it (My Applications on the upper left side):

Edit registrated app

Define a redirect URI that does really exist and can delegate to the PC, where your VS Code is running. The easiest way to use, is localhost, like http://localhost.

What happens is, that, when you start authorizing, your browser is open with a Spotify address, where you are asked, if your account wants to be connected with the app, you have registered:

Spotify OAuth page

The extension will request for the following scopes / permissions:

  • playlist-read-collaborative
  • playlist-read-private
  • streaming
  • user-library-read
  • user-read-playback-state

At the same time a HTTP server is started from VS Code on your local machine, that will wait for Spotify, which will connect to that server, when you click on OK.

Spotify will send an OAuth code to that server, that makes it possible to extend the feature list with the help of Web API:

OAuth code received from Spotify

Now copy all app data to your media.player settings in VS Code:

{
    "media.player": {
        "players": [
            {
                "name": "My Spotify player",
                "type": "spotify",

                "clientID": "<Client ID>",
                "clientSecret": "<Client Secret>",
                "redirectURL": "<Redirect URI>"
            }
        ]
    }
}

An entry supports the following, additional settings:

Name Description
clientID The client ID of an own registered Spotify app.
clientSecret The client secret of an own registered Spotify app.
redirectURL The redirect URL for the authorization.

To start the authorization process, click on the following, yellow button in your status bar:

Start Spotify OAuth

VLC []

To control your local VLC player, you have to activate Lua HTTP service.

First select Tools >> Preferences in the main menu:

VLC Setup Step 1

Show all settings and select the node Interface >> Main interfaces by activating Web in the Extra interface modules group:

VLC Setup Step 2

In the sub node Lua define a password in the Lua HTTP:

VLC Setup Step 3

Now save the settings and restart the application.

By default the HTTP service runs on port 8080.

If you already run a service at that port, you can change it by editing the vlcrc file, that contains the configuration. Search for the http-port value, change it (and uncomment if needed) for your needs (you also have to restart the player after that).

Look at the FAQ (search for Where does VLC store its config file?) to get information about where vlcrc is stored on your system.

Now update your settings in VS Code:

{
    "media.player": {
        "players": [
            {
                "name": "My VLC player",
                "type": "vlc",

                "password": "myPassword",
                "port": 8080
            }
        ]
    }
}

In that example, you can open localhost:8080/requests/status.xml to check your configuration. Use the password from the settings and leave the username field blank.

An entry supports the following, additional settings:

Name Description
host The host of the (Lua) HTTP service. Default localhost
password The password for the (Lua) HTTP service.
port The TCP port of the (Lua) HTTP service. Default 8080
showAllPlaylists Show all playlists or the first one only. Default (false)

Commands []

Press F1 to open the list of commands and enter one of the following commands:

Name Description ID
Media Player: Connect Connects to a player. extension.mediaPlayer.connect
Media Player: Disconnect Disconnects from a player. extension.mediaPlayer.disconnect
Media Player: Execute player action Executes a player action extension.mediaPlayer.executePlayerAction
Media Player: Register app for Spotify Opens the web page where a new app can be registrated. extension.mediaPlayer.spotify.registerApp
Media Player: Search Search for a track or playlist inside a player. extension.mediaPlayer.search
Media Player: Select item of playlist Selects an item of a playlist. extension.mediaPlayer.selectItemOfPlaylist
Media Player: Select output Selects an output device for a player. extension.mediaPlayer.selectPlayerOutput

Shortcuts []

If you want to define shortcuts / hotkeys for one or more of the upper commands, have a look at the VS Code article Key Bindings for Visual Studio Code.

vs-media-player's People

Contributors

mkloubert avatar

Stargazers

 avatar sʟxʀᴇ avatar 草苺奶昔LMT avatar  avatar Marcelo Antonio Lazo Chavez avatar Abraham Yusuf avatar Edward avatar Energy avatar 军舰 avatar  avatar Mark233 avatar  avatar Subhajit Sahu avatar failamir avatar Naufal Afif avatar Peter J. Mangelsdorf avatar yrming avatar Mark Cribbs avatar Roberto Plaza Romero avatar Nzix avatar xxxBadWolf avatar YL avatar Hans Koch avatar Paweł Zmarzły avatar shyyko.serhiy avatar Tommaso Ricci avatar Pierre Boissinot avatar Žan Pevec avatar Ruben Nic avatar

Watchers

James Cloos avatar  avatar Philipp Bauer avatar  avatar

vs-media-player's Issues

Tidal

Is it possibile to add support also for Tidal?

[vs-media-player] Could not find a playlist in '$(list-unordered)'!

Hey Marcel, do you know why I'm getting this error? I must be missing something or I need to do some additional digging into the extension files but yeah I'm curious! I can use the "Media Player: Select item of playlist" function but when I click on a playlist I get this warning message.

[vs-media-player] Could not find a playlist in '$(list-unordered)'!

Spotify commands not working

Nice extensions, but some commands for spotify does not work (next,previous track) even with web-api connection

Extension issue

  • Issue Type: Bug
  • Extension Name: vs-media-player
  • Extension Version: 3.1.0
  • OS Version: Windows_NT x64 10.0.19044
  • VS Code version: 1.69.2

⚠️ We have written the needed data into your clipboard. Please paste! ⚠️

Unknown track

for a few days i cannot see the track name, the other control works correctly. i have reinstalled the extension and changed client secret but still not working,

extension.mediaPlayer.spotify.registerApp not found

*Clean install on new pc
*Used Sync extension to install my setup
*Extension didn't load on status bar
*Uninstall extension, reload and reinstall to no success
*Expected behavior: Load player on status bar to connect with webapi
*Actual behavior:
image

Had to change computers on work, after instaling the extension e placing my previous working config when trying to register app it doesn't load the player.

Spotify Web API

There is a simpler way to authorize your extension without dyndns and port forwarding. Just use http://localhost as the redirect URL. Maybe if the authentication process is easier and better documented more users will use the extension.

Spotify broken after last spotilocal update

Every time I try to connect to Spotify, the extension cannot see that Spotify is open. This started recently, right after the spotilocal package got updated to 0.2.0.

I'd guess that forcing the extension to use 0.1.0 in package.json would probably do the trick, but I'm no expert.

Media Player Controls Doubled

Hello! I recently switched to this extension from shyykoserhiy.vscode-spotify and I noticed, that sometimes all my buttons duplicate.

My config for the extension is as follows:

"media.player": {
    "players": [
        {
            "name": "Spotify Player",
            "type": "spotify",
            "showVolumeButtons": true,
            "showRight": true,
            "clientID": "[redacted]",
            "clientSecret": "[redacted]",
            "redirectURL": "http://localhost"
        }
    ]
}

Versions

vs-media-player: v3.1.0
Visual Studio Code: v1.22.2

Cannot connect

the icon on the status bar is missing, when i select "Register to Spotify" the browser open https://developer.spotify.com/dashboard/applications, when i select "Connect" the result is Command 'Media Player: Connect' resulted in an error (It looks like Spotify isn't open. We failed to find spotilocal url with ports in range 4370-4380.) but in setting.json i have the Client id and secret for WebAPI

[vs-media-player] Spotify send no (valid) code!

Hi, I'm trying to do integration with the extension, when access to the redirect url displays the following message: Your account has been authorized with Spotify. You can close that browser / tab now, but when you access the visual code, it displays the following message at the top: [vs-media-player] Spotify send no (valid) code!

Spotify/VSCode URI

I don't understand if the URI is provided by VS or Spotify. If it's the first, how i set it? I'm using Ubuntu 16.04, VSCode and Spotify via WebAPI..

Icons on statusbar not showing.

A similar extension (https://github.com/ShyykoSerhiy/vscode-spotify/) has the same issue.

Quote from my comment over there:

(tested on v1.24, 1.25.0-insider and 1.27.0-insider)

I've noticed that spotify is listening on port 15132 and 8608. 8608 stays the same after restarting Spotify, 15132 becomes 17676.

I've checked via (powershell):
netstat -bano | Select-String spotify -Context 0,1

Remove $(triangle-right) for cleaner search results

Currently every song has $(triangle-right) appended to name (normally folded into a special character, but searching unfolds it - see screenshot). Thankfully it doesn't change order of songs (as strings with multiple matches get prioritized over those with single one), but it clutters UI. Please consider using special Unicode character or removing it altogether.

Screenshot

Failed to connect to spotify

The extension seems to be using an outdated version of spotilocal which is causing it to stop checking at port 4380 when it should be checking up to 4389 in the latest version of spotilocal.
My spotify uses the port 4381 therefor this extension does not work.

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.