HuGu - Vkontakte collective music player on node.js

    Why is this necessary? And let's recall the situation: several people work in the office, and one has music speakers connected to the computer. - “Vasya, change LoveRadio!” Set Ramstein! ” And Vasya, distracting from the report / game / thought: “Tired of Ramstein, let's put the“ Singing underpants ”better? Megazachotnye songs! "

    Can anyone add their favorite music to a shared playlist? Through the browser? From the VKontakte playlist? Yes maybe.

    HuGu - what is it?
    HuGu is an application under node.js that plays music from Vkontakte through a playlist shared by users.

    A little background.
    Like in any group of individuals, in our team (the team as a team, there are many of them all over the country, and I, like many, work in the development team), each developer wants to listen to music according to their preferences. Usually, of course, this is decided by individual headphones. But if there are common speakers, then you can listen together. For example, for a long time we used mocp on a common machine to create background music in the office. Everyone on 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 I set for myself? And he wrote a prototype application for several evenings. And we began to use it and forgot about mocp. And this New Year's weekend, I also wanted to join the trend, and I rewrote the application a little.

    Why HuGu?
    At first it was Hurdy-Gurdy ( Wheel Lyre , or simply a barrel organ), but for brevity they began to call HuGu.

    How does HuGu work?
    Under node.js, the web server and websocket server are launched. Each user visits the web server page and logs in via OAuth Vkontakte to the HuGu application. After authorization, the user can get his Vkontakte playlist and add songs to the playlist from it. All communication between the client and the server occurs via websocket messages.

    The playlist is queued up. On the server, we use mplayer to play mp3 files. Mplayer in turn plays the files added by users. You can also change the volume from the web interface (works via amixer).

    Did we do this for ourselves?
    Of course, first of all we use HuGu ourselves. Usually in the office there are 5-6 developers, each of whom periodically offers to listen to different compositions (last week we listened to different 8-bit tunes).

    The application somehow unfinished ...
    Well, until recently, it generally 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 to receive feedback. I will answer any questions, take into account the comments, I will use the recommendations. Especially regarding the code.

    Why is music only from Vkontakte?
    Vkontakte has a convenient API for receiving music. Many there have collections of their favorite compositions, from which you can quickly distribute music for listening in the office. Although, of course, Vkontakte sometimes slows down or even is unavailable - then you have to look for music on other resources or on the local machine, but it still rarely happens.

    By the way, a small list of radio stations has been 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 the IP addresses and / or domains where the redirect will be made in the application settings on Vkontakte.

    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 hosts on each machine that uses it, or use your own DNS server.

    Or use another treasure chest of music? Options?

    Why are songs removed from the playlist after playing?
    It happened historically. The playlist, as a turn, is convenient in that the lost songs are deleted, and they don’t bother us anymore, everyone sees that soon the turn will be suitable for a particular song.
    But my wife doesn’t really like it, she wants to like in the classic WinAmp: playlist and shuffle. And how would you be more comfortable?

    Those. Is HuGu a client server application?
    Well yes. Node.js is running on the server with our application, columns are also connected to the server. And all users through a browser connect to the server and play music there.

    The server can be someone else's work computer, or a specialized computer. For example, we use nettop (Foxconn Netbox DL-535W) with Ubuntu Server. And at home, HuGu is on my working desktop laptop (also Ubuntu), to which the speakers are connected, and the wife from her laptop (Windows), laying down on the couch, puts the 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 invite everyone to put their favorite song on their smartphone, and not as it usually happens: “Hey DJ! Put my CD! ”

    And you can not put separate speakers in the kitchen and not stream the audio stream there, as craftsmen do. And just from the tablet from the kitchen, turn up the volume on the speakers in the room.

    Where can I download?

    PS I wish you all a great collaborative development.

    Also popular now: