用java编写获取多媒体文件id3信息的Android代码
答案:2 悬赏:30 手机版
解决时间 2021-08-19 14:17
- 提问者网友:我的未来我做主
- 2021-08-19 03:40
就是读入一个多媒体文件,然后将其id3信息显示在手机屏幕上。
最佳答案
- 五星知识达人网友:像个废品
- 2021-08-19 03:54
$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=$second<b>".decbin($second)."</b><br>");
$third=ord(fread($this->fh,1));
$fourth=ord(fread($this->fh,1));
$this->info["version_id"]=($second&16)>0?(($second&8)>0?1:2):(($second&8)>0?0:2.5);
$this->info["version"]=$this->info_versions[$this->info]["version_id"]];
$this->info["layer_id"]=($second&4)>0?(($second&2)>0?1:2):(($second&2)>0?3:0); ;
$this->info["layer"]=$this->info_layers[$this->info]["layer_id"]];
$this->info["protection"]=($second&1)>0?"noCRC":"CRC";
$this->info["bitrate"]=$this->info_bitrates[$this->info]["version_id"]][$this->info]["layer_id"]][($third&240)];
$this->info["sampling_rate"]=$this->info_sampling_rates[$this->info]["version_id"]][($third&12)];
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=$second<b>".decbin($second)."</b><br>");
$third=ord(fread($this->fh,1));
$fourth=ord(fread($this->fh,1));
$this->info["version_id"]=($second&16)>0?(($second&8)>0?1:2):(($second&8)>0?0:2.5);
$this->info["version"]=$this->info_versions[$this->info]["version_id"]];
$this->info["layer_id"]=($second&4)>0?(($second&2)>0?1:2):(($second&2)>0?3:0); ;
$this->info["layer"]=$this->info_layers[$this->info]["layer_id"]];
$this->info["protection"]=($second&1)>0?"noCRC":"CRC";
$this->info["bitrate"]=$this->info_bitrates[$this->info]["version_id"]][$this->info]["layer_id"]][($third&240)];
$this->info["sampling_rate"]=$this->info_sampling_rates[$this->info]["version_id"]][($third&12)];
全部回答
- 1楼网友:刀戟声无边
- 2021-08-19 04:26
当前位置: > PHP如何调用JAVA 类库
PHP如何调用JAVA 类库
JAVA是个非常强大的编程利器,它的扩展库也是非常的有用,这篇教程,主要讲述怎样使用PHP调用功能强大的JAVA 类库(classes)。为了方便你的学习,这篇教程将包括JAVA的安装及一些基本的例子。 Windows下的安装 第一步:安装JDK,这是非常容易的,你只需一路回车的安装好。然后做好以下步骤。 在 Win9x 下加入 :“PATH=%PATH%;C:\jdk1.2.2\bin” 到AUTOEXEC.BAT文件中 在 NT 下加入 “;C:\jdk1.2.2\bin”到环境变量中。 这一步是非常重要的,这样PHP才能正确的找到需调用的JAVA类。 第二步:修改你的PHP.INI文件。 [java] extension=php_java.dll java.library.path=c:\web\php4\extensions\ java.class.path="c:\web\php4\extensions\jdk1.2.2\php_java.jar;c:\myclasses" 在PHP.INI中加入extension=php_java.dll,并在[java]中,设定好java.class.path,让它指向php_java.jar,如果你使用新的JAVA类,你也应该存入这个路径,在这篇例子中,我们使用c:\myclasses这个目录。 第三步:测试环境,创建如下PHP文件: <?php $system = new Java("java.lang.System"); print "Java version=".$system->getProperty("java.version")." <br>\n"; print "Java vendor=".$system->getProperty("java.vendor")." <p>\n\n"; print "OS=".$system->getProperty("os.name")." ". $system->getProperty("os.version")." on ". $system->getProperty("os.arch")." <br>\n"; $formatter = new Java("java.text.SimpleDateFormat","EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); print $formatter->format(new Java("java.util.Date"))."\n"; ?> 如果你正确安装了,你将会看到以下信息: Java version=1.2.2 Java vendor=Sun Microsystems Inc. OS=Windows 95 4.10 on x86 Wednesday, October 18, 2000 at 10:22:45 AM China Standard Time 这样,我们就已经成功的建立起了可以使用JAVA类的PHP运行环境,我们可以开始我们接下去的课程了。 例子1:创建和使用你自己的JAVA类 创建你自己的JAVA类非常容易。新建一个phptest.java文件,将它放置在你的java.class.path目录下,文件内容如下: public class phptest return str; } public String whatisfoo() /** * This is called if phptest is run from the command line with * something like * java phptes
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯