Skip to content

Commit

Permalink
session-changes - updated readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
masterwok committed Aug 10, 2018
1 parent 8adce50 commit b0a216b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ An Android torrent client library powered by [frostwire-jlibtorrent](https://git

## Usage

A single torrent download session is represented as the ```TorrentSession``` class. An instance of this class can be used to start, stop, pause, and resume a torrent download. When creating a new session, a ```TorrentSessionOptions``` instance along with a torrent ```Uri``` are required constructor parameters. The ```TorrentSessionListener``` interface can be implemented and set on the session to receive ```TorrentSessionStatus``` updates tied to the lifecycle of the torrent. The ```TorrentSessionBufferState``` is one of the properties of the status and represents the current state of the torrent piece buffer.
A single torrent download session is represented as the ```TorrentSession``` class. An instance of this class can be used to start, stop, pause, and resume a torrent download. When creating a new session, a ```TorrentSessionOptions``` instance is a required constructor parameter used to configure the session. The ```TorrentSessionListener``` interface can be implemented and set on the session to receive ```TorrentSessionStatus``` updates tied to the lifecycle of the torrent. The ```TorrentSessionBufferState``` is one of the properties of the status and represents the current state of the torrent piece buffer.

For example, the following code snippet sequentially downloads the largest file of the provided torrent to the downloads directory:

```kotlin
// http, https, magnet, file, and content Uri types are all supported.
val torrentUrl = Uri.parse("http://www.frostclick.com/torrents/video/animation/Big_Buck_Bunny_1080p_surround_frostclick.com_frostwire.com.torrent")
val torrentUri = Uri.parse("http://www.frostclick.com/torrents/video/animation/Big_Buck_Bunny_1080p_surround_frostclick.com_frostwire.com.torrent")

val torrentSessionOptions = TorrentSessionOptions(
downloadLocation = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
Expand All @@ -21,7 +21,7 @@ val torrentSessionOptions = TorrentSessionOptions(
, shouldStream = true
)

val torrentSession = TorrentSession(torrentUrl, torrentSessionOptions)
val torrentSession = TorrentSession(torrentSessionOptions)

torrentSession.listener = object : TorrentSessionListener {

Expand All @@ -33,7 +33,7 @@ torrentSession.listener = object : TorrentSessionListener {
) { ... }
}

torrentSession.start(context)
torrentSession.start(context, torrentUri)

```

Expand All @@ -53,7 +53,7 @@ and add the following in the dependent module:

```gradle
dependencies {
implementation 'com.github.masterwok:simple-torrent-android:0.4.2'
implementation 'com.github.masterwok:simple-torrent-android:0.5.1'
}
```
unless you're a fan of large APKs, you'll probably want to add the following to the build.gradle of your app so an APK is generated per ABI:
Expand Down

0 comments on commit b0a216b

Please sign in to comment.