Reading Remote MP3 File's ID3 Tags using Java

前端 未结 3 894
感情败类
感情败类 2020-12-18 15:03

I am looking for a way to read the ID3 tags from an MP3 file on a remote server without actually downloading the file. I have seen libraries like JAudioTagger and Entagged,

3条回答
  •  -上瘾入骨i
    2020-12-18 15:40

        String tmp="";
        int bytes_read;
    
        try{
            //RandomAccessFile file = new RandomAccessFile("/mnt/sdcard/Music/6 am (reggaeton).mp3", "r");
            RandomAccessFile file = new RandomAccessFile("/mnt/sdcard/Music/Jorge Vercilo - Final feliz.mp3", "r");
    
            long fsize=file.length();
            System.out.println("Abriu arquivo");
            byte[] buf = new byte[1024];
            bytes_read = file.read(buf, 0, 10);
            System.out.println("Leu "+String.valueOf(bytes_read));
            if(bytes_read==10){
                if(buf[0] == 'I' &&buf[1] == 'D' && buf[2] == '3') {
                    System.out.println("É ID3");
                    int version = (buf[4]<<8) + (buf[3] & 0xff);
                    System.out.println("Versão: "+String.valueOf(version));
                    if(buf[5] == 0x00) System.out.println("Clear flags");
                    long size = ((buf[9] & 0xFF) <<  0) |
                                ((buf[8] & 0xFF) <<  8) |
                                ((buf[7] & 0xFF) << 16) |
                                ((buf[6] & 0xFF) << 24);
                    System.out.println("Size: "+String.valueOf(size));
    
                    long p = 10;
                    long frame_size;
                    String encoding="";
                    while(p

提交回复
热议问题