Tuesday, February 27, 2007

Amarok playing directly from MTP device - part 2

Here is the part I promised yesterday with the changes I did to the mtpmediadevice files. The diff file can be found here. It is basically an implementation of the getProxyUrl(KURL&) call the way daapclient uses similar setup to map one url to another. Currently it is being done at the mediabrowser level as I could not figure out to do on-demand caching at mediaitem level. Moreover the MTP device has to be locked during each transfer which can be done only at MtpMediaDevice, so implementing it at MtpMediaItem/MtpTrack would have involved more complication. I will try to figure out if I can utilize any design pattern for this.
Another thing to note is I have only enabled it for doubleclick and returnpressed events so dnd and right click hasn't been enabled. Moreover copying the track to collectiondb and others do not use the cached file and neither are the cached files deleted after Amarok is shut down.

Monday, February 26, 2007

Amarok playing directly from MTP device - part 1

For the past couple of days I have been hacking into Amarok so that I can play media files directly from my MTP device by doubleclicking instead of first moving them to the collection and then to the playlist as I was led to believe in this post. It is working now and I will release the code in another post.
On the way I found this peculiar problem with KTempDir. When I use it to cache the media files, Amarok loses the metadata info associated with that MediaItem but if I use /tmp/ then it retains them. Here is the screenshot of the playlist ...

and here is the debugging output. Wrong one in red and right one in green.

amarok: [MtpMediaDevice] Proxy for: file://First_Of_May.mp3 is mtpcacheFosog7/First_Of_May.mp3
amarok: BEGIN: UrlLoader
amarok: [KDE::ProgressBar::ProgressBar(QWidget*, QLabel*)]
amarok: BEGIN: virtual void ThreadManager::Thread::run()
amarok: BEGIN: void EngineController::play(const MetaBundle&, uint)
amarok: [controller] Loading URL: mtpcacheFosog7/First_Of_May.mp3
amarok: [controller] Connecting to protocol:
amarok: BEGIN: virtual bool XineEngine::load(const KURL&, bool)
amarok: [xine-engine] Before xine_open() *****
amarok: [xine-engine] After xine_open() *****
amarok: [xine-engine] XINE_PARAM_EARLY_FINISHED_EVENT disabled
amarok: END__: virtual bool XineEngine::load(const KURL&, bool) - Took 0.048s
amarok: BEGIN: virtual bool XineEngine::play(uint)
amarok: BEGIN: void EngineSubject::stateChangedNotify(Engine::State)
amarok: [virtual void Amarok::StatusBar::engineStateChanged(Engine::State, Engine::State)] Line: 153
amarok: BEGIN: virtual void ContextBrowser::engineStateChanged(Engine::State, Engine::State)
amarok: END__: virtual void ContextBrowser::engineStateChanged(Engine::State, Engine::State) - Took 0.00069s
amarok: END__: void EngineSubject::stateChangedNotify(Engine::State) - Took 0.0048s
amarok: END__: virtual bool XineEngine::play(uint) - Took 0.0055s
amarok: BEGIN: void EngineSubject::newMetaDataNotify(const MetaBundle&, bool)
amarok: [Moodbar] Resetting moodbar:
amarok: END__: void EngineSubject::newMetaDataNotify(const MetaBundle&, bool) - Took 0.19s
amarok: END__: void EngineController::play(const MetaBundle&, uint) - Took 0.25s
amarok: [xine-engine] XINE_PARAM_EARLY_FINISHED_EVENT disabled
amarok: BEGIN: virtual void UrlLoader::completeJob()
amarok: END__: virtual void UrlLoader::completeJob() - Took 0.0003s
amarok: [ThreadManager] Job completed: UrlLoader. Jobs pending: 0
amarok: END__: UrlLoader - Took 0.47s


amarok: [MtpMediaDevice] Proxy for: file://Who S Crying Now.mp3 is /tmp/Who S Crying Now.mp3
amarok: BEGIN: UrlLoader
amarok: [KDE::ProgressBar::ProgressBar(QWidget*, QLabel*)]
amarok: BEGIN: virtual void ThreadManager::Thread::run()
amarok: BEGIN: void EngineController::play(const MetaBundle&, uint)
amarok: [controller] Loading URL: file:///tmp/Who%20S%20Crying%20Now.mp3
amarok: BEGIN: virtual bool XineEngine::load(const KURL&, bool)
amarok: [xine-engine] Before xine_open() *****
amarok: [xine-engine] After xine_open() *****
amarok: [xine-engine] XINE_PARAM_EARLY_FINISHED_EVENT disabled
amarok: END__: virtual bool XineEngine::load(const KURL&, bool) - Took 0.047s
amarok: BEGIN: virtual bool XineEngine::play(uint)
amarok: BEGIN: void EngineSubject::stateChangedNotify(Engine::State)
amarok: [virtual void Amarok::StatusBar::engineStateChanged(Engine::State, Engine::State)] Line: 153
amarok: BEGIN: virtual void ContextBrowser::engineStateChanged(Engine::State, Engine::State)
amarok: END__: virtual void ContextBrowser::engineStateChanged(Engine::State, Engine::State) - Took 0.00083s
amarok: END__: void EngineSubject::stateChangedNotify(Engine::State) - Took 0.0051s
amarok: END__: virtual bool XineEngine::play(uint) - Took 0.0059s
amarok: BEGIN: void EngineSubject::newMetaDataNotify(const MetaBundle&, bool)
amarok: [Moodbar] Resetting moodbar: /tmp/Who S Crying Now.mp3
amarok: [Moodbar] Moodbar::readFile: Trying to read /home/swapan/.kde/share/apps/amarok/moods/-1,.,tmp,Who S Crying Now.mood
amarok: [Moodbar] Moodbar::readFile: Trying to read /home/swapan/.kde/share/apps/amarok/moods/-1,.,tmp,Who S Crying Now.mood
amarok: [Moodbar] MoodServer::queueJob: Queued job for /tmp/Who S Crying Now.mp3, 1 jobs in queue.
amarok: [ContextBrowser] [CUEFILE]: /tmp/Who S Crying Now.cue - Shoot blindly and missed, searching for other cue files.
amarok: [ContextBrowser] [CUEFILE]: - Didn't find any matching cue file.
amarok: END__: virtual void ThreadManager::Thread::run() - Took 0.11s
amarok: BEGIN: virtual void ThreadManager::Thread::run()
amarok: END__: void EngineSubject::newMetaDataNotify(const MetaBundle&, bool) - Took 0.65s
amarok: END__: void EngineController::play(const MetaBundle&, uint) - Took 0.71s
amarok: BEGIN: virtual void UrlLoader::completeJob()
amarok: END__: virtual void UrlLoader::completeJob() - Took 0.00033s

Wednesday, February 21, 2007

Finished the SKY.fm integration

Finally I managed to finish the SKY.fm integration into Amarok using the ruby script. The script has to be installed in /tmp/kde-<user>/ folder for this to work. I will look into improving it. Currently just the SKY.fm scraping ruby file is available here and here is a snapshot of how it looks.


Tuesday, February 20, 2007

SKY.fm stream integration

Today I sat down to see if I could integrate SKY.fm streams into Amarok radio-streams and did come up with proof-of-concept. Basically the playlistbrowser fires up an external process and waits for it to fetch and parse the station names and playlists corresponding to those stations. Right now the external program is a hardcoded ruby script which is incomplete. The code works fine for the following /tmp/amarok-skyfm-pls.xml

<?xml version='1.0' encoding='UTF-8'?>
<stationlist>
<station name="Smooth Jazz" href="http://www.sky.fm/mp3/smoothjazz.pls" />
<station name="Top Hits" href="http://www.sky.fm/mp3/tophits.pls" />
<station name="The 80s" href="http://www.sky.fm/mp3/the80s.pls" />
<station name="Hit 70s" href="http://www.sky.fm/mp3/hit70s.pls" />
</stationlist>

Right now I need help with the script in scraping the stations and playlists off of the javascript file at fky.fm website. Code in diff -urNp output format is here (Check the next post instead). Here is a screenshot.

Saturday, February 17, 2007

Got vlc_engine working with 1.4.5

Finally got amarok 1.4.5 to recognize vlc-engine plugin and play streams and files on Kubuntu Edgy x86_64.

  1. I started with the ver0.2 source files posted by Eric Alber on the amarok mailing list available here and extracted it under amarok/src/engine directory. I did not have to modify MODULE_SYMBOL as I have 'vlc 0.8.6 Janus' running on my system.
  2. The first step was to add vlc subdirectory to the Makefile.am
    if with_vlc
    VLC_ENGINE_SUBDIR = vlc
    endif
    SUBDIRS += $(VLC_ENGINE_SUBDIR)
  3. Then I needed to modify/correct the amarok_vlc-engine_plugin.desktop file.
    X-KDE-Library=libamarok_vlc-engine_plugin
    X-KDE-Amarok-framework-version=28
  4. Then modified VlcEngine.cpp to return true for http streams in canDecode() function and implement unpause() virtual function.
    if (url.protocol() == "http")
    // play http streams
    return true;
    ------------------------------------
    void VlcEngine::unpause()
    {
    pause();
    }
  5. Then modified configure.in.in file in amarok directory to include VLC into generated ./configure script.
    ###############################################################################
    # BEGIN VLC CHECK
    ###############################################################################

    AC_ARG_WITH(vlc,
    AC_HELP_STRING([--with-vlc],[build Amarok with vlc-engine]),
    [build_vlc=$withval],
    [build_vlc=no]
    )

    if test "$build_vlc" != "no"; then
    AC_PATH_PROG(VLC_CONFIG, vlc-config, no)

    if test $VLC_CONFIG = "no"
    then
    amarok_warning_vlc_notfound=yes
    echo "amarok_warning_vlc_notfound: $amarok_warning_vlc_notfound"
    build_vlc=no
    else
    AC_DEFINE(HAVE_VLC, 1, [have VLC])
    CFLAGS_VLC=[`$VLC_CONFIG --cflags`]
    LIBS_VLC=[`$VLC_CONFIG --libs`]
    build_vlc=yes
    fi
    fi

    AM_CONDITIONAL(with_vlc, test x$build_vlc = xyes)
    AC_SUBST(CFLAGS_VLC)
    AC_SUBST(LIBS_VLC)

    ###############################################################################
    # END VLC CHECK
    ###############################################################################
  6. Then modified configure.in.bot file in amarok directory to tell whether vlc is included/excluded in configure.
    if test x$build_vlc = xno; then
    echo " = - vlc-engine"
    fi
    if test x$build_vlc != xno; then
    echo " = + vlc-engine"
    fi
  7. Then run "make -f Makefile.cvs" to generate the proper configure script. Then the usual steps like ./configure, make, make install. (Make sure that ./configure step creates the Makefile in the vlc directory.)
  8. Then extract vlc-settings.xml file from here in ~/.kde/share/apps/amarok directory and modified it according to my requirement.
  9. Next after running amarok, VLC engine should come up as one of the options in configuration->engine options.
Here is my new version of file with all the above modifications - amarok-vlc-engine-0.3.tgz

Friday, February 9, 2007

Extended amarokFS to contextFS

Here is a program inspired by amarokFS to show the context browser in fullscreen mode.

Tuesday, February 6, 2007

Fullscreen mode of Amarok

Now that somebody has developed a script called amarokFS to display fullscreen version of the player, it can be made the foundation for some of the ideas. Discussion at http://amarok.kde.org/forum/index.php/topic,13637.0.html

Monday, February 5, 2007

Improvement ideas for Amarok 2.0

I had posted some improvement ideas for Amarok on the forums at http://amarok.kde.org/forum/index.php/topic,13537.0.html
The gist of it is that Amarok is the only music player which is different from most of the linux music players where it's primary display is not to show howto manage music collections but show what it is playing and it's associated information such as lyrics, artist info, listening habits and the artist's community.

MTP devices don't play nice with Amarok

Subsequent to my earlier post, I have come to know that MTP devices don't play very nice with Amarok. One of the main drawbacks is that one cannot play a track directly from the device. Instead he has to copy it to the collections db to play it. So that means I cannot preview the song before copying it to my main collection.
The reason for this is that the internal url for those tracks are kept as file://. and since technically it is not mounted on the root folder, amarok cannot find it at that location. Instead it should store something like mtp://., so that when amarok asks for it a proper handler for mtp:// can read the track and send it to amarok to play. See the discussion at http://amarok.kde.org/forum/index.php/topic,13614.0.html

Amarok and Nokia Nseries

Glorious day today (it was a few days back), finally got Amarok detect my Nokia N75 as a media/MTP device and I can browse the playlist. This site was really helpful. I suppose this can be applied to any Nokia S60 3rd generation phones. Next I have to make it play and transfer tracks.

Hindi module for wiki-lyrics script

I have added iTRANS/hindi as an extension to wiki_lyrics script available here. Now it has been folded into the main script and cleaned up. Make sure that the itrans executable is the one for your platform. The default script has i386 executable whereas the original has both i386 and x86_64 version of the itrans executable.

Only load scripts with .spec file

I have modified the scriptmanager to load only those scripts which have .spec files associated with them - here. This way it will avoid to load every executable scripts under the scripts directory and will load only those which have associated .spec file.

lyrics page has conditional 'Powered by' line

I have modified the lyrics viewer of contextbrowser not to show 'Powered by' line if site and site_url tags not present in .spec file (in cases where the scripts want to handle them selves) - here.

Hindi lyrics script for Amarok

Created a lyrics script to fetch lyrics of hindi songs from giitaayan.com and show them in devnagari script using iTRANS. It falls back on Lyrc or Astraweb for non-indian songs. The latest version can be downloaded from http://www.kde-apps.org/content/show.php?content=50890 or an earlier version here.

Starting a new blog ...


I am starting a new blog to post about my trials and tribulations while playing with and listening to Amarok. Started out with version 1.4.4 from Kubuntu repository. Currently as of Feb 11th, I am running version 1.4.5-SVN patch 632592 with two of my own changes.