java获取id3v2的简单介绍

博主:adminadmin 2023-01-11 23:03:07 946

本篇文章给大家谈谈java获取id3v2,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

用java编写获取多媒体文件id3信息的Android代码

$this-error="Nosuchfile"; if($exitonerror)$this-exitonerror(); } } functionexitonerror(){ echo($this-error); exit; } functionset_id3($title="",$author="",$album="",$year="",$comment="",$genre_id=0){ $this-error=false; $this-wfh=fopen($this-file,"a"); fseek($this-wfh,-128,SEEK_END); fwrite($this-wfh,pack("a3a30a30a30a4a30C1","TAG",$title,$author,$album,$year,$comment,$genre_id),128); fclose($this-wfh); } functionget_id3(){ $this-id3_parsed=true; fseek($this-fh,-128,SEEK_END); $line=fread($this-fh,10000); if(preg_match("/^TAG/",$line)){ $this-id3=unpack("a3tag/a30title/a30author/a30album/a4year/a30comment/C1genre_id",$line); $this-id3["genre"]=$this-id3_genres_array[$this-id3]["genre_id"]]; return(true); }else{ $this-error="noidv3tagfound"; return(false); } } //get_info()helpermethods functioncalculate_length($id3v2_tagsize=0){ $length=floor(($this-info["filesize"]-$id3v2_tagsize)/$this-info["bitrate"]*0.008); $min=floor($length/60); $min=strlen($min)==1?"0$min":$min; $sec=$length`; $sec=strlen($sec)==1?"0$sec":$sec; return("$min:$sec"); } functionget_info(){ // $this-get_id3v2header(); $second=$this-synchronize(); // echo("2ndbyte=$secondb".decbin($second)."/bbr"); $third=ord(fread($this-fh,1)); $fourth=ord(fread($this-fh,1)); $this-info["version_id"]=($second16)0?(($second8)0?1:2):(($second8)0?0:2.5); $this-info["version"]=$this-info_versions[$this-info]["version_id"]]; $this-info["layer_id"]=($second4)0?(($second2)0?1:2):(($second2)0?3:0); ; $this-info["layer"]=$this-info_layers[$this-info]["layer_id"]]; $this-info["protection"]=($second1)0?"noCRC":"CRC"; $this-info["bitrate"]=$this-info_bitrates[$this-info]["version_id"]][$this-info]["layer_id"]][($third240)]; $this-info["sampling_rate"]=$this-info_sampling_rates[$this-info]["version_id"]][($third12)];

java识别文件是否是mp3文件

        File srcFile = new File (src);

        srcFile.listFiles (new FilenameFilter ()

        {

            @Override

            public boolean accept ( File dir, String name )

            {

                // TODO

                return false;

            }

        });

java合并MP3文件

代码没问题

是这样的每个MP3由两到三个部分构成:ID3v2标签+MP3声音+(ID3v1标签),后面一个不一定有。

其中的标签就是MP3的各种信息,比如说歌曲名、演唱者、唱片封面什么的

所以按你这种直接合并的方式,合并出来的就是:

标签+MP3声音+标签+标签+MP3声音+标签

自然中间就有一段没有声音了

建议你参考标签格式,对于MP3文件进行处理,然后再合并就好了

id3官网: (英文的)

或者你可以直接搜索id3v2很多资料都可以用

java获取id3v2的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、java获取id3v2的信息别忘了在本站进行查找喔。