songdataprovider

A simple library to grab song data to build a music library app

License

License

Categories

Categories

IDE Development Tools Data
GroupId

GroupId

com.ericchee
ArtifactId

ArtifactId

songdataprovider
Last Version

Last Version

1.0.8
Release Date

Release Date

Type

Type

aar
Description

Description

songdataprovider
A simple library to grab song data to build a music library app
Project URL

Project URL

https://github.com/echeeUW/SongDataProvider
Source Code Management

Source Code Management

https://github.com/echeeUW/SongDataProvider

Download songdataprovider

How to add to project

<!-- https://jarcasting.com/artifacts/com.ericchee/songdataprovider/ -->
<dependency>
    <groupId>com.ericchee</groupId>
    <artifactId>songdataprovider</artifactId>
    <version>1.0.8</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.ericchee/songdataprovider/
implementation 'com.ericchee:songdataprovider:1.0.8'
// https://jarcasting.com/artifacts/com.ericchee/songdataprovider/
implementation ("com.ericchee:songdataprovider:1.0.8")
'com.ericchee:songdataprovider:aar:1.0.8'
<dependency org="com.ericchee" name="songdataprovider" rev="1.0.8">
  <artifact name="songdataprovider" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.ericchee', module='songdataprovider', version='1.0.8')
)
libraryDependencies += "com.ericchee" % "songdataprovider" % "1.0.8"
[com.ericchee/songdataprovider "1.0.8"]

Dependencies

compile (5)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-parcelize-runtime jar 1.4.32
» unspecified jar
org.jetbrains.kotlin : kotlin-stdlib-jdk7 jar 1.4.32
androidx.appcompat » appcompat jar 1.2.0
androidx.core » core-ktx jar 1.3.2

Project Modules

There are no modules declared in this project.

SongDataProvider

This library provides simple classes & functions to show basic Song data.

Usage

To use this library, add this implementation line to your build.gradle (app) dependencies block:

dependencies {
    ...
    implementation("com.ericchee:songdataprovider:1.0.8@aar")
}

Documentation

Song

Song is a data model class that contains info about an individual song

data class Song(
    val id: String,
    val title: String,
    val artist: String,
    val durationMillis: Long,
    val smallImageID: Int,
    val largeImageID: Int
): Parcelable

smallImageID and largeImageID are drawable resource ID's. Use ImageView.setImageResource() to set drawable as imageView's source.

Note: This class Song is Parcelable meaning it can be passed through Intents

SongDataProvider.getAllSongs()

Use SongDataProvider.getAllSongs() to get a list of Songs

val allSongs: List<Song> = SongDataProvider.getAllSongs()

val firstSong: Song = allSongs[1]
val artistName: String = firstSong.artist

SongDataProvider.createRandomSong()

The method createRandomSong() can be used to create a quick song with generic song info.

val randomSong: Song = SongDataProvider.createRandomSong()

SongDataProvider.createSong()

The method createSong() can be used to create a quick song where the ID, & duration will be auto generated for you

Definition:

fun createSong(
    title: String,
    artist: String,
    id: String = "${System.currentTimeMillis()}$title:$artist",
    durationMillis: Long = Random.nextLong(
        60000,
        300000
    )
): Song

Usage):

val thrillerSong: Song = SongDataProvider.createSong("Thriller", "Michael Jackson")

Notice how a song id & duration are optional. They will be auto-generatoed upon creation

Versions

Version
1.0.8
1.0.7
1.0.6