Android歌词秀设计思路(5)歌词播放服务(4)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-10 12:24 点击:次
return mLyricAdapter.getLyric(index);
}
public long seekToLyric(int index){
long position = mLyricAdapter.getLyricTime(index);
if(position != -1){
return seek(position);
}else{
return 0;
}
}
public void seekToPrevLyric(){
int curLyric = mLyricAdapter.getCurrentLyric();
if(curLyric > 0){
seekToLyric(curLyric - 1);
}
}
public void seekToNextLyric(){
int curLyric = mLyricAdapter.getCurrentLyric();
if(curLyric < mLyricAdapter.getLyricCount() - 1){
seekToLyric(curLyric + 1);
}
}
所剩不多了,重载onCompletion是想在这个时刻关闭Timer的同时,将这一变化通知个mLyricPlayerListener.
@Override
public void onCompletion(MediaPlayer mp) {
if(mLyricTimer.isRunging()){
mLyricTimer.stopTimer();
}
if(mLyricPlayerListener != null){
mLyricPlayerListener.onStateChanged();
}
super.onCompletion(mp);
}
最后是继承LyricAdapter.LyricListener需要的两个方法。将来自LyricAdapter的通知转送给已经登录的mLyricPlayerLister。之所以这样做是希望利用者在使用时可以简单一些。
@Override
public void onLyricChanged(int lyric_index){
if(mLyricPlayerListener != null){
mLyricPlayerListener.onLyricChanged(lyric_index);
}
}
@Override
public void onLyricLoaded(){
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>