Code Monkey home page Code Monkey logo

lyricviewx's Introduction

LyricViewX

LyricViewX is a beautiful Lyrics control for Android.

Based on LrcView design.

中文点击这里(可能不是最新)

Compare with LrcView

  • 100% Kotlin code
  • Interaction optimization, removing outdated methods
  • Provide the JitPack Library for easy use
  • Provide new functionality

How to use

Step 1. Add the JitPack repository to the build file Add it to build.gradle(root) :

allprojects {
    repositories {
        ...
        maven { url 'https://www.jitpack.io' }
    }
}

Step 2. Add dependencies

dependencies {
    implementation 'com.github.Moriafly:LyricViewX:#Tag' // replace $Tag with lastest version
}

In layout

<com.dirror.lyricviewx.LyricViewX
    android:id="@+id/lyricViewX"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:lrcPadding="16dp">
</com.dirror.lyricviewx.LyricViewX>

In activity

val lyricViewX = findViewById<LyricViewX>(R.id.lyricViewX)
lyricViewX.loadLyric()

Functions

/**
 * Set font color for non-current line lyrics [normalColor]
 */
fun setNormalColor(normalColor: Int)

/**
 * font size of normal lyrics text [size], unit px
 */
fun setNormalTextSize(size: Float)

/**
 * Current text size of lyrics
 */
fun setCurrentTextSize(size: Float)

/**
 * Sets the font color for the current line of lyrics
 */
fun setCurrentColor(currentColor: Int)

/**
 * Sets the font color selected when dragging lyrics
 */
fun setTimelineTextColor(timelineTextColor: Int)

/**
 * Sets the color of the timeline when dragging lyrics
 */
fun setTimelineColor(timelineColor: Int)

/**
 * Sets the font color to the right when dragging lyrics
 */
fun setTimeTextColor(timeTextColor: Int)

/**
 * Set lyrics to the text [label] displayed in the center of the screen when empty, such as "No lyrics yet".
 */
fun setLabel(label: String)

/**
 * Load the lyrics file
 * Lyric timestamps need to be consistent in both languages
 * @param mainLyricFile First language lyrics file
 * @param secondLyricFile Optional, second language song lyrics file
 */
fun loadLyric(mainLyricFile: File, secondLyricFile: File? = null)

/**
 * Load the lyric text
 * Lyric timestamps need to be consistent in both languages
 * @param mainLyricText First language lyric text
 * @Param secondLyricText optional, second language lyric text
 */
fun loadLyric(mainLyricText: String?, secondLyricText: String? = null)

/**
 * Load online lyrics
 * @Param lyricUrl The web address of the lyrics file
 * @param charset encoding format
 */
fun loadLyricByUrl(lyricUrl: String, charset: String? = "utf-8")

/**
 * Refresh lyrics
 * @param time Current playback time
 */
fun updateTime(time: Long)

/**
 * Sets whether dragging of lyrics is allowed
 * @Param draggable whether dragging is allowed
 * @Param onPlayClickListener sets lyrics drag after playback button click listener, if drag is allowed, it cannot be null
 */
fun setDraggable(draggable: Boolean, onPlayClickListener: OnPlayClickListener?)

/**
 * Set click
 */
fun setOnSingerClickListener(onSingerClickListener: OnSingleClickListener?)

/**
 * @NewAdded
 * Get the current lyrics of each line entity, can be used for lyrics sharing
 * @Return LyricEntry collection
 */
fun getLyricEntryList(): List<LyricEntry>

/**
 * When the play button is clicked, it should jump to the specified play position
 * @return whether the event was successfully consumed, if so, the UI will be updated
 */
fun onPlayClick(time: Long): Boolean

/**
 * Click events
 */
fun onClick()

ScrollInterpolator

If you want to use a custom scroll interpolator, you can use the following code:

// Set the custom interpolator
val interpolator = LinearInterpolator()
lyricViewX.smoothScrollInterpolator = interpolator

License

LyricViewX  Copyright (C) 2021-2022 Moriafly
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

lyricviewx's People

Contributors

moriafly avatar cy745 avatar

Watchers

Md. Mehedi Hasan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.