在Android上播放歌曲时显示时间 [英] show time when song is playing in android

查看:147
本文介绍了在Android上播放歌曲时显示时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用给定列表中的MediaPlayer播放歌曲.我希望包括歌曲从开始到结束的持续时间.如何增加时间以及如何从0:00更新时间直到歌曲结束

i am trying to play a song by using MediaPlayer from the given list.i want include time duration for the song from starting to ending of the song. how to add time and how to update that time from 0:00 to till the end of that song

推荐答案

您可以使用方法getCurrentPosition()给出以毫秒为单位的当前位置.

You can use the method getCurrentPosition() which gives you the current position in milliseconds.

您还可以使用方法getDuration()来获取歌曲的完整长度.

You can also use the method getDuration() to get the full length of the song.

您可以使用单独的线程来更新计时器.

You can use a separate thread to update the timer.

这篇关于在Android上播放歌曲时显示时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆