The developers behind the open source Amarok audio player have announced the official release of version 2.0, a long-awaited Amarok update for KDE 4. Amarok 2.0 offers a totally new user interface, extensive integration with various web-based audio services, support for a multitude of new KDE 4 technologies, and many other important changes.

Amarok, which was first released in 2003 by developer Mark Kretschmann, became one of the most popular and widely-used KDE applications on the Linux desktop. The program is adored by its users for delivering a massive amount of power and flexibility in a very functional interface that leverages a wide range of KDE's capabilities. The new version brings the power of Amarok into the KDE 4 era with many significant improvements.

Although Amarok 2 largely stays true to its roots, there have been some highly controversial changes along the way. One move that has attracted criticism is the adoption of MySQL Embedded for Amarok's internal database and the decision to drop support for other database options. The major overhaul also forced the developers to drop a few features, such as playlist filtering and support for portable audio devices, that will eventually be brought back in future versions. Although a few of the major changes in version 2 will create some transitional difficulties for some users, the program itself is is now on a much stronger foundation for future innovation.

The user interface has been restructured with some major changes. The active playlist is displayed on the right-hand side in a new list view that prominently displays album art and groups together consecutive songs that are from the same album. This makes it easy to reorder these groupings together. Album art is also displayed in the improved collection manager.

The center of the user interface is dominated by the contextual information area, which is implemented with Plasma. The decision to adopt Plasma inside of Amarok generated some controversy, but the move brought some pretty big advantages. Plasma, which was first introduced in KDE 4 for the new desktop shell, allows developers to build flexible interactive widgets—called plasmoids—that provide an interface to an underlying data engine. Plasmoids are easy to develop and can be made in several other programming languages, including Ruby and C#. Supporting Plasma in Amarok will make it easier for users to extend the program and build new components that can be used in the context area.

The context area in the final release is much improved over what we saw in previous prereleases. It has a paging system so that users can lay out several different sets of plasmoids and switch between them by clicking through the list. There is also a button that allows users to zoom out and see thumbnails of all the pages so that they can select the one that they want to jump to. The concept appears to be closely modeled after Plasma's activity system in KDE 4.

Amarok 2 ships with several plasmoids, most of which are designed to display additional information about the currently playing song. These include plasmoids for track info, song lyrics, and Wikipedia information. Their contents will change automatically when new songs start to play. The Plasma context area is also used for drag-and-drop interaction with the application. When you drag songs from the collection over the context area, it will change and display an interactive list with some of the options from the item's context menu. You can activate one of the actions in the list by dropping songs onto it.

Although the Plasma-based context area has some great functionality, it also has some weaknesses and limitations. The font rendering in Amarok plasmoids is terrible and it makes the text difficult to read. The layout is also very awkward in some places. For example, the controls for managing plasmoids overlap the bottom plasmoid in the container. Amarok is the first KDE application to make extensive use of embedded Plasma elements, so that aspect of the program is still experimental in some ways. Plasma support will likely improve in future versions as Plasma continues to mature.

Scripting



One of the major features in 2.0 is a new scripting engine that allows developers to extend the program and add additional functionality using QtScript, a programming language that is based on the ECMAScript standard.

Amarok's QtScript integration was implemented by Peter Zhou as a Google Summer of Code project. A significant portion of Amarok's functionality is now exposed through the scripting APIs, including support for manipulating playlists and collections, controlling playback, and customizing the user interface. QtScript supports Qt's signal and slot callback model, which means that scripts can also bind functions to application events. In several blog entries written earlier this year, Zhou demonstrated how to use some of those capabilities.

As an experiment, I made my own Amarok script that will detect when a new song starts playing and then automatically post the title and artist to Twitter:

/* Qt Twitter Script SegPhault (Ryan Paul) */ Importer.loadQtBinding("qt.core"); Importer.loadQtBinding("qt.network"); Amarok.Engine.trackChanged.connect(function() { var TrackInfo = Amarok.Engine.currentTrack(); /* This should probably use the toPercentEncoding function instead of replace, but I couldn't figure out how to convert its QByteArray output back into a regular string */ var txt = ("Listening to " + TrackInfo.title + " by " + TrackInfo.artist).replace(" ", "%20") http = new QHttp("www.twitter.com"); http.setUser("segphault", "XXXXX"); http.post("/statuses/update.xml?status=" + txt, new QByteArray()); });

Amarok has a lot of other advanced scripting capabilities that go much deeper than the example above. Amarok's scripted services API makes it possible for developers to use QtScript to add support for entirely new external content providers. Amarok's tight integration with the Librivox public domain audiobook provider is one example of a QtScript-based service. The code for this service is remarkably concise and ability to add services in this manner has helped contribute to the large number of content sources that will work right out of the box in Amarok 2.

Amarok scripts can even have their own custom user interfaces. Last month, Zhou showed that it is possible to build a graphical user interface with the Qt Designer tool and then dynamically load the XML user interface description file into Amarok and display it at runtime with QtScript. This is achieved by leveraging the QUiLoader class from the QtUiTools library.

Another really intriguing Amarok 2 scripting example is the Amarok webcontrol interface, which was created by Ian Monroe and is still in an early stage of development. In a blog entry written a few months ago, Monroe explains that he used QTcpServer and QHttp to build a lightweight web server in QtScript that will allow users to remotely control Amarok.

Conclusion



After extensive testing, I'm convinced that Amarok 2 is a major improvement. Although it still has some weak areas that need improvement and there are still some missing features that need to be brought back, the overall user experience is better and the new infrastructure will make it possible for the player to evolve faster. I am especially impressed with its scripting capabilities and I think that this extensibility will enable end users to do a lot of innovative things with the program.

Amarok 2 is available for download from the project's web site and has already been packaged for several distributions. For more details, see the official release notes.