【发布时间】:2015-08-03 09:41:10
【问题描述】:
我在 Google App Engine Cloud Storage 中存储了 mp3 文件,我想获取它们的持续时间。 我在这里的一个人的帮助下编写了这段代码,但不幸的是,AudioSystem 类不适用于 Google App Engine Cloud Storage。 有人知道怎么做吗?
ListResult lr = gcsService.list(mybucketname, ListOptions.DEFAULT);
while (lr.hasNext() && playlistLength > 0) {
ListItem li = lr.next();
String filename = li.getName();
GcsService gcsService =
GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(new GcsFilename(mybucketName, fileName), 0, 1024 * 1024);
AudioInputStream audioInputStream;
try (InputStream in = Channels.newInputStream(readChannel)) {
audioInputStream = AudioSystem.getAudioInputStream(in);
}
long frames = audioInputStream.getFrameLength();
double durationInSeconds = (frames+0.0) / format.getFrameRate();
playlistLength-=(int)(durationInSeconds)/60;
这是返回的错误:
Error for /hello java.lang.NoClassDefFoundError: javax.sound.sampled.AudioSystem is a restricted class.
Please see the Google App Engine developer's guide for more details.
at com.google.apphosting.runtime.security.shared.stub.javax.sound.sampled.AudioSystem.<clinit>(AudioSystem.java)
【问题讨论】:
-
“不起作用”是什么意思?我们需要更多信息。
-
这就是我从堆栈跟踪中获得的全部信息:/hello java.lang.NoClassDefFoundError 的错误:javax.sound.sampled.AudioSystem 是一个受限类。有关详细信息,请参阅 Google App Engine 开发人员指南。
-
那么.....在来这里之前,您是否查看了谷歌应用引擎开发人员指南以了解更多详细信息? :)
-
是的。而且我找不到其他方法。
-
那么,你从“受限类”中得到了什么信息?它应该指出它为什么不起作用,然后您可以根据它不起作用的原因推断您的解决方案
标签: google-app-engine servlets mp3 google-cloud-storage duration