HuGu - the collective player of Vkontakte music on node.js
Why is this necessary? And let us recall the situation: several people work in the office, and one has music speakers connected to the computer. - “Vasya, change LoveRadio! Put Ramstein! ”And Vasya, distracting himself from the report / game / thought:“ I got tired of Ramstein, let's put the “Singing Pants” better? Megaphone songs! ”
Can everyone add their favorite songs to the general playlist? Through the browser? From playlist Vkontakte? Yes maybe.
HuGu - what is it?
HuGu is an application for node.js, which plays music from Vkontakte on the playlist, which users together make up.
A bit of background
As in any group of individuals, in our team (the team as a team, there are such people all over the country, and I, like many, work in the development team), each developer wants to listen to music according to his preferences. Usually, of course, this is solved by individual headphones. But if there are common speakers, then you can listen together. For example, we used mocp on a shared machine for a long time to create musical background in the office. Each ssh could deliver a song.
')
One day last summer, Ilya (another developer from our team, not me) decided to try node.js. And what's the point of trying if there is no interesting task that you set for yourself? And I wrote a prototype of the application for several evenings. And we began to use it and forgot about mocp. And in these New Year's holidays, I also wanted to join the trend, and I rewrote the application a little.
Why HuGu?
Initially, it was Hurdy-Gurdy ( Wheel Lira , or simply a barrel organ), but for brevity they began to call HuGu.
How does HuGu work?
Under node.js, the web server and the websocket server are started. Each user enters the web server page and authorizes through OAuth VKontakte to the HuGu application. After authorization, the user can get his playlist Vkontakte and from it add songs to the playlist. All communication between the client and the server occurs via websocket messages.
Playlist is arranged on the principle of queuing. On the server, we use mplayer to play mp3 files. Mplayer in turn loses files added by users. You can also change the volume from the web interface (works through amixer).
Did we do this for ourselves?
Of course, first of all, we ourselves use HuGu. Usually there are 5-6 developers in the office, each of which periodically offers to listen to different compositions (last week we listened to different 8-bit tunes).
Somehow the application looks unfinished ...
Well, recently it looked like this:
But the work continues. In JavaScript, “I'm not a wizard yet, I'm just learning,” so I post information about HuGu for feedback. I will answer any questions, take into account the comments, use the recommendations. Especially concerning the code.
Why is music only from Vkontakte?
Vkontakte has a convenient API for getting music. Many of them have collections of favorite songs from which you can quickly play music for listening in the office. Although, of course, sometimes Vkontakte slows down or even becomes unavailable - then you have to look for music on other resources or on a local machine, but this rarely happens.
By the way, a small list of radio stations was added as an experiment. For sometimes you notice that you are sitting in silence or simply do not know what you want to listen to.
But OAuth VKontakte?
Here the biggest trouble, i.e. when creating a Vkontakte web application, which are clients in a web browser, you have to specify in the application settings in Vkontakte ip-addresses and / or domains, where the redirect will be sent.
Two solutions to the problem:
1. Create your own application, specify your ip-address in it. In the HuGu settings, specify the id of the Vkontakte application.
2. Use the domain music.local , which I added to my application. But you must either register it in the hosts on each machine using it, or use your own DNS server.
Or use another treasure trove of music? Options?
And why are songs deleted from the playlist after playing?
It happened historically. A playlist as a queue is convenient because the lost songs are deleted, and they no longer interfere with us, everyone sees that the turn for one or another composition will soon come up.
But my wife doesn’t like it very much, she wants it in the classic WinAmp: playlist and shuffle. And how would you be more comfortable?
Those.Is HuGu a client server application?
Well yes. On the server, node.js works with our application, columns are also connected to the server. And all users through the browser connect to the server and play music there.
The server can be someone's work computer, or a specialized computer. We, for example, use nettop (Foxconn Netbox DL-535W) with Ubuntu Server. At home, I have HuGu on my desktop desktop (also Ubuntu), to which the speakers are connected, and the spouse from her laptop (Windows), lying on the couch, puts on music. Very comfortably.
How else can you use HuGu?
Soon there will be corporate parties on the occasion of lovers, real men and beautiful women - you can offer everyone to put their favorite song from their smartphone, and not as it usually happens: “Hey DJ! Put on my CD! ”
And you can also not put separate columns in the kitchen and not stream audio stream there, as craftsmen do. And just from the tablet from the kitchen to add volume to the speakers in the room.