Skip to content

Commit

Permalink
chore(docs): Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Mar 5, 2024
1 parent efe9d1c commit 551ae15
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[![](https://jitpack.io/v/doublesymmetry/KotlinAudio.svg)](https://jitpack.io/#doublesymmetry/KotlinAudio)


KotlinAudio is an Android audio player written in Kotlin, making it simpler to work with audio playback from streams and files.

Inspired by [SwiftAudioEx](https://github.com/doublesymmetry/SwiftAudioEx). Our aim is to have feature parity with the iOS equivalent.

_[Blaze](https://runblaze.dev) sponsors KotlinAudio by providing super fast Apple Silicon based macOS Github Action Runners. Use the discount code `RNTP50` at checkout to get 50% off your first year._

## Example

Expand All @@ -16,6 +16,7 @@ Choose "kotlin-audio-example" in the run target and run it in a simulator
(or on an actual device).

## Requirements

minSDK 21

## Installation
Expand All @@ -29,7 +30,9 @@ implementation 'com.github.doublesymmetry:kotlinaudio:v2.0.0'
## Usage

### AudioPlayer

To get started playing some audio:

```swift
let player = AudioPlayer()
let audioItem = DefaultAudioItem(audioUrl: "someUrl", type: MediaType.DEFAULT)
Expand All @@ -38,6 +41,7 @@ player.load(item: audioItem, playWhenReady: true) // Load the item and start pla

To listen for events in the `AudioPlayer`, subscribe to events found in the `event` property of the `AudioPlayer`.
To subscribe to an event:

```kotlin
// jetpack compose
val state = player.event.stateChange.collectAsState(initial = AudioPlayerState.IDLE)
Expand All @@ -47,7 +51,9 @@ player.event.stateChange.collect {}
```

#### QueuedAudioPlayer

The `QueuedAudioPlayer` is a subclass of `AudioPlayer` that maintains a queue of audio tracks.

```swift
let player = QueuedAudioPlayer()
let audioItem = DefaultAudioItem(audioUrl: "someUrl", type: MediaType.DEFAULT)
Expand All @@ -57,14 +63,17 @@ player.add(item: audioItem, playWhenReady: true) // Since this is the first item
When a track is done playing, the player will load the next track and update the queue.

##### Navigating the queue

All `AudioItem`s are stored in either `previousItems` or `nextItems`, which refers to items that come prior to the `currentItem` and after, respectively. The queue is navigated with:

```swift
player.next() // Increments the queue, and loads the next item.
player.previous() // Decrements the queue, and loads the previous item.
player.jumpToItem(index:) // Jumps to a certain item and loads that item.
```

##### Manipulating the queue

```swift
player.remove(index:) // Remove a specific item from the queue.
player.removeUpcomingItems() // Remove all items in nextItems.
Expand Down

0 comments on commit 551ae15

Please sign in to comment.