Giter Site home page Giter Site logo

asr-pub / lyricviewdemo Goto Github PK

View Code? Open in Web Editor NEW
678.0 15.0 113.0 27.63 MB

LyricView is a powerful and flexible custom view to display lyrics within music player under Android

Home Page: https://github.com/zhengken/LyricViewDemo

Java 100.00%
musicplayer lyrics android

lyricviewdemo's Introduction

LyricView

LyricView is a powerful and flexible custom view to display lyrics within music player under Android

Screenshot

LyricViewDemo.apk YouTube

Usage

Gradle dependency

step 1 Add the JitPack repository to your build file
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

step 2 Add the dependency
dependencies {
        compile 'com.github.zhengken:LyricViewDemo:v1.2'
}

XML code

//step 1
<me.zhengken.lyricview.LyricView
        android:id="@+id/custom_lyric_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Java code

//step 2
LyricView mLyricView = (LyricView)findViewById(R.id.custom_lyric_view);

//step 3
mLyricView.setLyricFile(lyricFile);

//step 4, update LyricView every interval
mLyricView.setCurrentTimeMillis(progress);

//step 5, implement the interface when user drag lyrics and click the play icon
mLyricView.setOnPlayerClickListener(new LyricView.OnPlayerClickListener() {
        @Override
        public void onPlayerClicked(long progress, String content) {
            
        }
    });

XML attributes

Attributes Format Default Description
fadeInFadeOut boolean false Enable lyrics fadeInFadeOut or not
hint string No Lyrics Display when not exist lyric file
hintColor color #FFFFFF The color of hint text
textSize dimension 16sp The text size of lyrics
textColor color #8D8D8D The color of lyrics
highlightColor color #FFFFFF The color of current lyric that playing
textAlign enum CENTER The alignment of lyrics
maxLength dimension 300dp Line feed when lyric'width beyond maxLength
lineSpace dimension 25dp Line space

Java API

Methods Description
setOnPlayerClickListener(OnPlayerClickListener listener) Callback when click the play icon
setAlignment(@Alignment int alignment) Set the alignment of the lyrics
setCurrentTimeMillis(long current) Scroll lyrics to the specify TimeMillis
setLyricFile(File file) Set the lyric file, and auto set the charset by juniversalchardet-1.0.3
setLyricFile(File file, String charset) Set the lyric file with the specified charset
setTypeface(Typeface typeface) Set the typeface of lyrics
reset() Reset the LyricView

Thanks

@码农小阿飞

License

Copyright 2016 kkkkk

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

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

lyricviewdemo's People

Contributors

asr-pub avatar fioneragh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lyricviewdemo's Issues

需要呈现两种不同的字号.

image

首先谢谢您的开源.

现在项目需要的是,播放着的字体,能够呈现红色,而播放过和未播放的呈现fadein和fadeout,并且,除播放的那一行呈现大字,其他呈现小字,我看了api,没有设置两种字体的api,都是统一设置歌词的大小.

然后fadein和fadeout 也不是特别能够满足需求,

再次感谢您的开源.

lrc的解析

感谢你的轮子:) 在使用中遇到一个问题,歌词[00:00.00]的解析是写死的,我在解析网易云音乐的歌词的时候部分是[00:00.000]的,解析失败,所以自己down了文件修改的,可以改进一下:0

Error:(770, 60) error: cannot find symbol variable index

LyricViewDemo Master\lyricview\src\main\java\me\zhengken\lyricview\LyricView.java
Error:(770, 60) error: cannot find symbol variable index

private long measureStartTimeMillis(String str) { long minute = Long.parseLong(str.substring(1, 3)); long second = Long.parseLong(str.substring(4, 6)); long millisecond = Long.parseLong(str.substring(7, index)); // this index not found return millisecond + second * 1000 + minute * 60 * 1000; }

在重新设置歌词文件时有一些小问题

我读了一下您的源码,在1个参数的setLyricFile方法里,在设置歌词文件时有用新的歌词文件路径与mCurrentLyricFilePath变量进行比较,如果相同则不继续进行操作,并且在之前如果判断新的文件不存在或为null后在reset后就返回了。那么当我现在已经设置了一个歌词并有效的时候,接下来我设置了一个不存在的歌词文件,则View会reset变为没有歌词的显示状态,然后我又重新设置上一次有效的歌词时,因为mCurrentLyricFilePath没有变化,会导致没法将歌词重新显示出来。2个参数的setLyricFile则没有问题,但是这个没有重新设置歌词和判断编码的功能。

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.