Android歌词秀设计思路(2)歌词处理(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-10 12:23 点击:次
}
//将歌词的时间字符串转化成毫秒数的Utility类,如果参数是00:01:23.45
private static class TimeParser{
//@return value in milliseconds.
static long parse(String strTime){
String beforeDot = new String("00:00:00");
String afterDot = new String("0");
//将字符串按小数点拆分成整秒部分和小数部分。
int dotIndex = strTime.indexOf(".");
if(dotIndex < 0){
beforeDot = strTime;
}else if(dotIndex == 0){
afterDot = strTime.substring(1);
}else{
beforeDot = strTime.substring(0, dotIndex);//00:01:23
afterDot = strTime.substring(dotIndex + 1); //45
}
long intSeconds = 0;
int counter = 0;
while(beforeDot.length() > 0){
int colonPos = beforeDot.indexOf(":");
try{
if(colonPos > 0){//找到冒号了。
intSeconds *= 60;
intSeconds += new Integer(beforeDot.substring(0, colonPos));
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>