In 2012-2013, I found one online radio that “hooked” me with a large selection of good music and the fact that there was (almost) no advertising.
In my position I am a web developer, and I am also interested in various technologies and developments in science, and therefore I often open a large number of tabs in the browser, and often also several profiles in the browser. And if you add to this the development environment, the graphics editor, open folders, then at least get a navigator through all the open windows and tabs.
Music in the tab in the browser I played most of the time. When I needed to pause playback to answer a call or watch an interesting video, I had to first find the browser window I needed, then the tab I needed, and only after that I could press the cherished pause button.
This happened often, and I increasingly began to ask myself to find a solution to this problem.
Without thinking twice, I decided to write an extension for the browser that would allow you to control the playback using hotkeys (in the terminology of some browsers, shortcuts).
And often I was interested to know the artist and the name of the work, so it was decided to add pop-up alerts with this information.
Today, my extension allows you to control playback on several sites (SoundCloud, Digitally Imported, VKontakte, Odnoklassniki, Online Radio 101.ru, VGM Radio), as well as some other actions (add the current track to the playlist, mark the track as you like, change the volume sound). This is done both with the help of shortcuts, and with the help of buttons in the notification (the buttons are not displayed in Opera).
There are also (disabled) alerts with information about the track when the status of the player changes or by pressing shortcuts.
Also, a list of the last ten tracks with the ability to search for these VK, Google and Amazon.
The extension has an API to add support for other sites.
Each site (player) is added as a module. There are built-in and external modules.
Built-in modules are part of my extension and their settings are available on the expansion settings page. In order to connect the module, the user must give the extension its permission to access the tabs and the content of the pages of the respective domains.
External modules are separate extensions that connect to my expansion through the API and have access to all of my expansion options (player control using shortcuts and buttons in the notification, as well as a list of recent tracks). Their settings are also available on the settings page of my extension.
The API is available under the MIT license on GitHub (see References below).
It is written on ES5 to lower the entry barrier for third-party developers, but this should not stop those who want to write their module on more modern specifications and technologies.
There are: two external modules (available as separate extensions), as well as one built-in module using the API.
Built-in or external module? "... that is the question," as the classic said.
If you want to use the API and add support for the new player, use the following hints:
Questions, complaints and suggestions are welcome. Leave them in the comments or use one of the other methods .
Source: https://habr.com/ru/post/306072/