psychopy 音频时长代码_音频时长的相关问题

1、我把1.mp3的音频文件上传到服务器,代码如下

@Override

public void addGoods(Map params) throws Exception {

dao.addGoods(params);

if (params.containsKey("photo"))

MyUtils.fileAdd("hn_goods" + File.separatorChar + params.get("go_id").toString(), params.get("photo").toString());

}

这里都是没有问题的

2.public static void fileAdd(String path,String file) throws IOException {

if (file != null && file.length() > 0) {

String[] photos = file.split(",");

String basePath = uploadPath + path + File.separatorChar;

File baseFile = new File(basePath);

if (!baseFile.exists())baseFile.mkdirs();

String sourcePath = uploadPath + "temp" + File.separatorChar;

for (String p:photos) {

File sourceFile = new File(sourcePath + p);

FileChannel srcChannel = new FileInputStream(sourceFile).getChannel();

FileChannel dstChannel = new FileOutputStream(basePath + p).getChannel();

dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

srcChannel.close();

dstChannel.close();

sourceFile.delete();

}

}

封装的路径什么的都在这里

3、哪位大神可以告诉我,我要取项目中服务器上的1.mp3音频文件的时长怎么取路径??

File file = new File("。。。。。。。。。。。。????");

try {

MP3File f = (MP3File)AudioFileIO.read(file);

MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader();

System.out.println(audioHeader.getTrackLength());

} catch(Exception e) {

e.printStackTrace();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值