Hi vlc-devel,<br><br>my name is Peter Grundström and I work on the Last.fm Client Team. VLC already have support for scrobbling (The act of reporting to Last.fm what you just listen to) but this is by using our webservices directly. This patch also adds support for scrobbling via the official client, if available. This have some advantages like having more information about the track in the Last.fm client and also have access the socialnetwork aspects.<br>
<br>I was a bit uncertain if to make this a whole new module but I chose to integrate it in the existing. Please tell me if you would like it the other way around.<br><br>When this patch is applied the audioscrobbler module will try to scrobble through the client if possible. This works by opening a socket to the Last.fm client and the sending commands over it. If it fails it will revert to use the webservices directly. The only time you will lose scrobbles is if you start playing a track while the Last.fm client is running and the close it before the you reach the scrobblepoint ( 4 min or middle of the track ). This is as far as I can see impossible to fix since we cant know when the Last.fm client closes and if we scrobble the same track twice we will trigger spam protection. <br>
<br>Here are some comments on the changes I made:<br><br>> - a = encode_URI_component( psz_meta ); \<br>> + a = strdup( psz_meta ); \<br><br>The audioscrobbler module earlier stored the metadata of the track in percent encoding. This is the right format when sending it to the webservice, but wont work when sending it through the socket to the client. I changed it to store the metadata unencoded and then encode it before it sends it to the webservice or through the socket.<br>
<br>> input_item_GetURL( p_item );<br><br>One of the problems I had was not being able to get a hold of the path of the current file. Is the above function the one I'm supposed to use.<br><br>Another one was that when the VLC is closed I need to send the stop command to Last.fm. I tried sending the command in several places Close, Unload and Run (audioscrobbler is dying part...). But every time the thread gets killed before the Last.fm client has time to read from the other end of the socket. Please advise.<br>
<br>> +static int TransmitStart ( intf_thread_t *p_this );<br>> +static int TransmitStop ( intf_thread_t *p_this );<br>> +static int TransmitResume ( intf_thread_t *p_this );<br>> +static int TransmitPause ( intf_thread_t *p_this );<br>
> +static int Transmit ( intf_thread_t *p_this, const char* message );<br><br>This is the functions where the magic happens. Transmit opens a socket to the Last.fm client and sends a message. The Transmit* functions creates the appropriate messages for that action and calls Transmit.<br>
<br>While doing this I also found a bug in the old code (still present). If you enable scrobbling and then dont enter a username and password, the client will crash when trying to scrobble via the webservice.<br><br>j-b: The thing we talked about regarding the Pvlc flag in the call to the webservice. I talked to max about it and it's not necessary but if you do we can give you statistics over how many scrobbles made from VLC.<br>
<br>Attached is a git diff over my changes.<br><br>--<br>Regards<br>Peter Grundtröm<br>Last.fm Client Team<br><br>