Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
More copy r/p
Browse files Browse the repository at this point in the history
  • Loading branch information
bradfloodx committed Aug 16, 2024
1 parent ccaada6 commit 48c1999
Show file tree
Hide file tree
Showing 84 changed files with 243 additions and 299 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ jobs:
# Comment this and the with: above out for performance testing on a branch
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Build Example App
run: ./gradlew :kotlin-audio-example:assembleDebug
run: ./gradlew :kotlin-audio-pro-example:assembleDebug
2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2022 Double Symmetry GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
78 changes: 78 additions & 0 deletions README-ORIGINAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# KotlinAudioPro

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

## Example

To see the audio player in action, run the example project!
To run the example project, clone the repo, then open in Android Studio.
Choose "kotlin-audio-pro-example" in the run target and run it in a simulator
(or on an actual device).

## Requirements

minSDK 21

## Installation

### Gradle

```gradle
implementation 'com.github.evergrace-co:kotlinaudio:v2.0.0'
```

## Usage

### AudioPlayer

To get started playing some audio:

```swift
let player = AudioPlayer()
let audioItem = DefaultAudioItem(audioUrl: "someUrl", type: MediaType.DEFAULT)
player.load(item: audioItem, playWhenReady: true) // Load the item and start playing when the player is ready.
```

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)

// normal
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)
player.add(item: audioItem, playWhenReady: true) // Since this is the first item, we can supply playWhenReady: true to immedietaly start playing when the item is loaded.
```

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.
```

## License

KotinAudio is available under the MIT license. See the LICENSE file for more info.
97 changes: 3 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,5 @@
# KotlinAudio
# KotlinAudioPro

[![](https://jitpack.io/v/doublesymmetry/KotlinAudio.svg)](https://jitpack.io/#doublesymmetry/KotlinAudio)
A minimalist and opinionated audio player written in Kotlin, with a focus on high audio quality and simple integration.

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.

<div align="left" valign="middle">
<a href="https://runblaze.dev">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://www.runblaze.dev/logo_dark.png">
<img align="right" src="https://www.runblaze.dev/logo_light.png" height="102px"/>
</picture>
</a>

<br style="display: none;"/>

_[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._

</div>

## Example

To see the audio player in action, run the example project!
To run the example project, clone the repo, then open in Android Studio.
Choose "kotlin-audio-example" in the run target and run it in a simulator
(or on an actual device).

## Requirements

minSDK 21

## Installation

### Gradle

```gradle
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)
player.load(item: audioItem, playWhenReady: true) // Load the item and start playing when the player is ready.
```

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)

// normal
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)
player.add(item: audioItem, playWhenReady: true) // Since this is the first item, we can supply playWhenReady: true to immedietaly start playing when the item is loaded.
```

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.
```

## License

KotinAudio is available under the MIT license. See the LICENSE file for more info.
Built exclusively for [react-native-audio-pro](https://github.com/evergrace-co/react-native-audio-pro).

This file was deleted.

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ plugins {
}

android {
namespace = "com.example.kotlin_audio_example"
namespace = "com.example.kotlin_audio_pro_example"
compileSdk = 34

defaultConfig {
applicationId = "com.example.kotlin_audio_example"
applicationId = "com.example.kotlin_audio_pro_example"
minSdk = 21
targetSdk = 34
versionCode = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example
package com.example.kotlin_audio_pro_example

import android.content.res.Configuration.UI_MODE_NIGHT_YES
import android.os.Bundle
Expand Down Expand Up @@ -29,19 +29,19 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.doublesymmetry.kotlinaudio.models.AudioPlayerState
import com.doublesymmetry.kotlinaudio.models.DefaultAudioItem
import com.doublesymmetry.kotlinaudio.models.MediaSessionCallback
import com.doublesymmetry.kotlinaudio.models.MediaType
import com.doublesymmetry.kotlinaudio.models.NotificationButton
import com.doublesymmetry.kotlinaudio.models.NotificationConfig
import com.doublesymmetry.kotlinaudio.models.RepeatMode
import com.doublesymmetry.kotlinaudio.models.PlayerConfig
import com.doublesymmetry.kotlinaudio.players.QueuedAudioPlayer
import com.example.kotlin_audio_example.ui.component.ActionBottomSheet
import com.example.kotlin_audio_example.ui.component.PlayerControls
import com.example.kotlin_audio_example.ui.component.TrackDisplay
import com.example.kotlin_audio_example.ui.theme.KotlinAudioTheme
import co.evergrace.kotlinaudiopro.models.AudioPlayerState
import co.evergrace.kotlinaudiopro.models.DefaultAudioItem
import co.evergrace.kotlinaudiopro.models.MediaSessionCallback
import co.evergrace.kotlinaudiopro.models.MediaType
import co.evergrace.kotlinaudiopro.models.NotificationButton
import co.evergrace.kotlinaudiopro.models.NotificationConfig
import co.evergrace.kotlinaudiopro.models.RepeatMode
import co.evergrace.kotlinaudiopro.models.PlayerConfig
import co.evergrace.kotlinaudiopro.players.QueuedAudioPlayer
import com.example.kotlin_audio_pro_example.ui.component.ActionBottomSheet
import com.example.kotlin_audio_pro_example.ui.component.PlayerControls
import com.example.kotlin_audio_pro_example.ui.component.TrackDisplay
import com.example.kotlin_audio_pro_example.ui.theme.KotlinAudioTheme
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ext
package com.example.kotlin_audio_pro_example.ext

fun Long.millisecondsToString(): String {
val seconds = this / 1000
Expand All @@ -11,4 +11,4 @@ fun Long.millisecondsToString(): String {
} else {
String.format("%02d:%02d", minutes, remainingSeconds)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ui.component
package com.example.kotlin_audio_pro_example.ui.component

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -48,4 +48,4 @@ fun InnerSheet(onRandomMetadata: () -> Unit = {}) {
@Composable
fun ActionBottomSheetPreview() {
InnerSheet()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ui.component
package com.example.kotlin_audio_pro_example.ui.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -20,7 +20,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.kotlin_audio_example.ui.theme.KotlinAudioTheme
import com.example.kotlin_audio_pro_example.ui.theme.KotlinAudioTheme

@Composable
fun PlayerControls(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ui.component
package com.example.kotlin_audio_pro_example.ui.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
Expand All @@ -17,9 +17,9 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.example.kotlin_audio_example.R
import com.example.kotlin_audio_example.ext.millisecondsToString
import com.example.kotlin_audio_example.ui.theme.KotlinAudioTheme
import com.example.kotlin_audio_pro_example.R
import com.example.kotlin_audio_pro_example.ext.millisecondsToString
import com.example.kotlin_audio_pro_example.ui.theme.KotlinAudioTheme

@Composable
fun TrackDisplay(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ui.theme
package com.example.kotlin_audio_pro_example.ui.theme

import androidx.compose.ui.graphics.Color

Expand All @@ -8,4 +8,4 @@ val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Pink40 = Color(0xFF7D5260)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ui.theme
package com.example.kotlin_audio_pro_example.ui.theme

import android.app.Activity
import android.os.Build
Expand Down Expand Up @@ -67,4 +67,4 @@ fun KotlinAudioTheme(
typography = Typography,
content = content
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.kotlin_audio_example.ui.theme
package com.example.kotlin_audio_pro_example.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
Expand Down Expand Up @@ -31,4 +31,4 @@ val Typography = Typography(
letterSpacing = 0.5.sp
)
*/
)
)
File renamed without changes.
Loading

0 comments on commit 48c1999

Please sign in to comment.