第一范文网 - 专业文章范例文档资料分享平台

MP3音乐播放器论文

来源:用户分享 时间:2025/5/30 0:53:02 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

青岛理工大学毕业论文(设计)

String temp; int i=0; //创建一个正则表达式

Pattern p=Pattern.compile(\String result=null; boolean b=true;

while((temp=bufferedReader.readLine())!=null){

i++;

Matcher m=p.matcher(temp); if(m.find()){//如果找到时间点

if(result!=null){

messages.add(result);}

String timeStr=m.group();//把匹配的部分返回一个String Long time=timeToLong(timeStr.substring(1,

timeStr.length()-1));//去掉中括号后转化为long

if(b){times.offer(time);//队列中插入}

String msg=temp.substring(10);//Message为10之后得字符 result=\加上一个换行符}

else{result=result+temp+\没时间点时追加}} messages.add(result); queues.add(times); queues.add(messages);

}catch(Exception e){

e.printStackTrace();} return queues;}

把歌词信息和播放时间与进度条控制信息传递回Activity的主要函数如下: lass UpdateTimeCallback implements Runnable {

33

青岛理工大学毕业论文(设计)

ArrayList queues = null;

public UpdateTimeCallback(ArrayList queues) {

this.queues = queues;}

public void run() {

Queue times = queues.get(0); Queue messages = queues.get(1); // currentTimeMillis()获取当前系统时间,以毫秒

long offset = System.currentTimeMillis() - begin;// 偏移量,从开始播放

到现在一共过了多少时间

if (currentTimeMill == 0) {

nextTimeMill = (Long) times.poll();

// 强制类型转化用Long,nextTimeMill下次歌词更新的时间 message = (String) messages.poll();// 歌词信息}

if (offset >= nextTimeMill)// 偏移时间稍微大于或等于下次歌词更新时

间时更新

{

Intent intent = new Intent(); // 歌词控制

intent.setAction(AppContent.LRC_MESSAGE_ACTION); intent.putExtra(\sendBroadcast(intent);

if (messages != null && times != null) {

message = (String) messages.poll(); nextTimeMill = (Long) times.poll();}}

// 进度条和播放时间控制 Intent intent = new Intent(); // 歌词控制

34

青岛理工大学毕业论文(设计)

}

intent.setAction(AppContent.LRC_MESSAGE_ACTION); intent.putExtra(\durationTime = mediaPlayer.getDuration(); intent.putExtra(\

intent.putExtra(\sendBroadcast(intent);

if (durationTime == mediaPlayer.getCurrentPosition())

stopSelf();

currentTimeMill = currentTimeMill + 10;

handler.postDelayed(updateTimeCallback, 10);// 延后10毫秒再执行一次 }

广播接收器,主要作用是接收Service所发送的广播,并且更新UI,也就是更新TextView,Activity中的接受与处理函数如下:

class LrcMessageBroadcastReceiver extends BroadcastReceiver{

public void onReceive(Context context, Intent intent) {

//从Intent对象中,取出歌词信息,然后更新TextView //System.out.println(\接收到广播启动更新\String lrcMessage=intent.getStringExtra(\lrcTextView.setText(lrcMessage); //设置进度条

int durationTime=intent.getIntExtra(\seekBar.setMax(durationTime);

int playingtime=intent.getIntExtra(\seekBar.setProgress(playingtime); //设置播放时间

int minute=playingtime/1000/60;

35

青岛理工大学毕业论文(设计)

int second=playingtime/1000`; if(second<10)

timeTextView.setText(\

}

}

else timeTextView.setText(\

36

搜索更多关于: MP3音乐播放器论文 的文档
MP3音乐播放器论文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c2laph5yj111lh1d7s6yg_10.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top