⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readsong.java

📁 这是一个简单的用JMF完成的播放器软件
💻 JAVA
字号:
/*
 * ReadSong.java
 *
 * Created on 2008年4月1日, 下午5:21
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.gjun.huxiaoming;
import java.io.*;
import java.util.*;
import java.awt.List;
import java.util.ArrayList;
/**
 *
 * @author Administrator
 */
public class ReadSong {
    private List list=new List();
    private ArrayList arrayTime=new ArrayList();
    int n=0;
    /** Creates a new instance of ReadSong */
    public ReadSong(String fileName) 
    {
        StringBuffer buffer=new StringBuffer(fileName);
        StringBuffer newBuffer=buffer.replace(buffer.length()-3,
                buffer.length(),"lrc");
        
        String newFileName=newBuffer.toString();
    try {
         Scanner sc= new Scanner(new FileReader(newFileName));
        sc=sc.useDelimiter(":|\n");
        for(int i=0;i<4;i++)
        {
           String st=sc.next();
           String name=sc.next();
          StringBuffer sb=new StringBuffer(name);
         String context= sb.substring(0,sb.length()-2);
           System.out.println(context);
           list.add(context);
        }
       //  sc=sc.useDelimiter("]|\n");
       while(sc.hasNextLine())
       {
           String context=sc.nextLine();
           StringBuffer buffer1=new StringBuffer(context);
           
            /*int k=buffer1.indexOf("]");
            int i=buffer1.indexOf("[");
            String time=buffer1.substring(i,k);
            setArrayTime(time);
            buffer1.delete(0,k+1);*/
           
           while(buffer1.indexOf("]")>0)
           {
            int k=buffer1.indexOf("]");
           
            int i=buffer1.indexOf("[");
            if(k>=0&&i>=0)
            {
            String time=buffer1.substring(i,k);
            setArrayTime(time);
            
            }
            buffer1.delete(0,k+1);
           }
           String newContext=buffer1.toString();
          
           System.out.println(newContext);
           list.add(newContext);
           //System.out.println("the time is"+time);
         //  String context=sc.next();
          // System.out.println(context);
       }
        } catch (FileNotFoundException ex) {
          //ex.printStackTrace();
            list.add("找不到歌词,请先下载");
        }
     
   }
    public List getList()
    {
        return list;
    }
    public void setArrayTime(String songTime)
    {
        StringBuffer bufferTime=new StringBuffer(songTime);
        long playTime=0;
      int i= bufferTime.indexOf("0");
      int k=bufferTime.indexOf(".");
     // int j=bufferTime.indexOf("]");
      String seconds=bufferTime.substring(i,i+2);
      if(!seconds.equals("0"))
      {
          playTime=(Long.parseLong(seconds))*60*1000;
      }
      String nextSecond=bufferTime.substring(i+3,k);
      if(nextSecond.startsWith("0"))
      {
          nextSecond=nextSecond.substring(1);
      }
      playTime+=(Long.parseLong(nextSecond))*1000;
      String millisecond=bufferTime.substring(k);
      if(millisecond.startsWith("0"));
      {
          millisecond=millisecond.substring(1);
      }
      playTime+=(Long.parseLong(millisecond));
      arrayTime.add(n,playTime);
      n++;
      System.out.println("the time is "+playTime);
    }
    public ArrayList getArrayTime()
    {
        return(arrayTime);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -