项目作者: zhehuaz

项目描述 :
A netease-like scrolling lyric view.
高级语言: Java
项目地址: git://github.com/zhehuaz/LyricView.git
创建时间: 2016-10-20T11:33:07Z
项目社区:https://github.com/zhehuaz/LyricView

开源协议:Apache License 2.0

下载


LyricView

Demo

A netease-music-like scrolling lyric view.

Features

  • Parsing .lrc file
  • Auto scrolling
  • Text highlight
  • Manual progress select
  • Multi-language display
  • Karaoke effect

Usage

Copy module lrcparser and uilibrary to your project.

Declare it like this in your XML:

  1. <me.zhehua.uilibrary.LyricView
  2. android:id="@+id/lv_main"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:background="#212121"></me.zhehua.uilibrary.LyricView>

And call this to initialize the view in OnCreate():

  1. mLyricView = (LyricView) findViewById(R.id.lv_main);
  2. InputStream lrcStream = getResources().openRawResource(R.raw.sample);
  3. try {
  4. LyricAdapter lyric = new SimpleLyricAdapter(lrcStream);
  5. lrcStream.close();
  6. mLyricView.setLyricAdapter(lyric);
  7. } catch (IOException e) {
  8. e.printStackTrace();
  9. }

Or you can use DoubleLyricAdatper initialized with two streams to show a two-way display lyric view.

If no adpter fits your need, use a custom adatper extending LyricAdapter.

When setLyricAdapter() is called, the lyric view starts to build.

Then call

  1. mLyricView.startScroll();

to start the scroll.

Be careful that you have to call this after the view in activity is shown.

It’s safe to call this in Activity#onWindowFocusChanged(boolean).

If you’re not sure about this, get the proper time by calling:

  1. mLyricView.setReadyListener(new LyricView.OnLyricReadyListener() {
  2. @Override
  3. public void onReady(View view) {
  4. do something...
  5. }
  6. });

Contribute

Thanks a lot for contribute to this repo by coding or issues.
New PRs on develop branch please~

License

  1. Copyright 2016 Zhehua Zhang
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.