Updated scrobbling.md (formatting)

Removed useless extra backticks around in-line code, and added some more around methods and classes names.
This commit is contained in:
Melvyn Laïly 2015-06-20 09:55:53 +02:00
parent d2fdbf1b10
commit 6aa6146498

View File

@ -9,7 +9,7 @@
## Quickstart
```IScrobbler``` provides an interface for scrobbler classes. The ```Inflatable.Lastfm``` package comes with a basic scrobbler that does not support caching; to get caching you can use the SQLiteScrobbler provided in ```Inflatable.Lastfm.SQLite``` package, or you can [integrate your own database](#extensibility).
`IScrobbler` provides an interface for scrobbler classes. The `Inflatable.Lastfm` package comes with a basic scrobbler that does not support caching; to get caching you can use the SQLiteScrobbler provided in `Inflatable.Lastfm.SQLite` package, or you can [integrate your own database](#extensibility).
Create the scrobbler class:
```c#
@ -50,22 +50,22 @@ If used in a music app, this code should be used immediately after a track has f
### Scrobbles are sent in batches of 50
The Last.fm API supports up to 50 scrobbles being sent at a time. This is handled for you when using an IScrobbler class from the SDK.
The Last.fm API supports up to 50 scrobbles being sent at a time. This is handled for you when using an `IScrobbler` class from the SDK.
### There is a limit on how many scrobbles may be sent in each day
There must be at least 30 seconds in between each scrobble. This means you may scrobble at most ```(24 * 60 * 60) / 30 = 2880``` tracks in one day. If this limit is reached then the scrobbles will be cached if it's enabled.
There must be at least 30 seconds in between each scrobble. This means you may scrobble at most `(24 * 60 * 60) / 30 = 2880` tracks in one day. If this limit is reached then the scrobbles will be cached if it's enabled.
### Scrobbling is opportunistic
As currently implemented, Scrobblers will only scrobble when the ScrobbleAsync() method is called. Any cached scrobbles will be sent then, and only then. As an illustration, this is a scenario involving our friendly test-subject, User:
As currently implemented, Scrobblers will only scrobble when the `ScrobbleAsync()` method is called. Any cached scrobbles will be sent then, and only then. As an illustration, this is a scenario involving our friendly test-subject, User:
- User is commuting to their employment at Business Corporation. They are listening to a playlist of track1, track2 and track3.
- The application is set up to call scrobbler.ScrobbleAsync() when a track is finished playing.
- The application is set up to call `scrobbler.ScrobbleAsync()` when a track is finished playing.
- User's train enters a tunnel.
- When track1 finishes, User has no network connection. If caching is enabled, then the scrobble is cached.
- User's train exits the tunnel.
- When track2 finishes, User now has a network connection. The call to scrobbler.ScrobbleAsync() inspects its cache, and ends up sending both track1 and track2.
- When track2 finishes, User now has a network connection. The call to `scrobbler.ScrobbleAsync()` inspects its cache, and ends up sending both track1 and track2.
- User is content in the presence of accurate statistics.
- User's train enters another tunnel.
- Track3 finishes playing, but User has no network connection. The scrobble for track3 is cached for later.
@ -73,17 +73,17 @@ As currently implemented, Scrobblers will only scrobble when the ScrobbleAsync()
At this point, track1 and track2 have been scrobbled - but track3 has not! Track3 is in the scrobble cache. It is not until User's commute, back to their residence in Townsville, when they listen to track4. Only when track4 is finished playing will track3 be scrobbled.
Solving this problem requires some sort of background task to empty the cache. You can write your own that calls ```scrobbler.SendCachedScrobblesAsync()```.
Solving this problem requires some sort of background task to empty the cache. You can write your own that calls `scrobbler.SendCachedScrobblesAsync()`.
### Scrobbles have an age limit
Last.fm do not accept scrobbles which are older than two weeks (UTC). There's no point sending them, so Scrobbles passed to ScrobbleAsync() which are older than two weeks will be silently dropped.
Last.fm do not accept scrobbles which are older than two weeks (UTC). There's no point sending them, so Scrobbles passed to `ScrobbleAsync()` which are older than two weeks will be silently dropped.
Right now there is no way to know when this happens. At some point this information will be made available in the reponse object. (#issue number tba)
## Extensibility
The ScrobblerBase class may be extended in your own project to integrate with the database that suits you best. The derived class needs to implement ```GetCachedScrobblesAsync()```, which should return an IEnumerable<Scrobble>, and ```CacheAsync(Scrobble s)``` which should return LastResponseStatus.Cached if successful or throw an exception if not. Exceptions thrown in CacheAsync() will be caught and returned to the user as error codes (see: #5).
The `ScrobblerBase` class may be extended in your own project to integrate with the database that suits you best. The derived class needs to implement `GetCachedScrobblesAsync()`, which should return an `IEnumerable<Scrobble>`, and `CacheAsync(Scrobble s)` which should return `LastResponseStatus.Cached` if successful or throw an exception if not. Exceptions thrown in `CacheAsync()` will be caught and returned to the user as error codes (see: #5).
### SQLite