我希望有人能帮我解决这个问题。我有一个情况,我需要添加音频文件,已开发的FLA文件。为此,我必须打开fla文件,创建一个新的层,将音频剪辑拖到该层,将所有的层扩展到音频剪辑的末尾,并添加一个停止。
我希望用JSFL为我做这件事。目前,我可以在库中选择音频剪辑,并运行我的JSFL脚本。我拿那个声音剪辑,并把它添加到一个新的层。它创建了另一个层,并在最后一个帧添加了一个停止。我也可以扩展所有的层,无论我想要多少帧。我的问题是,我似乎不知道如何获得声音剪辑的长度,所以我知道要延长所有的层。
任何帮助都会很好。
谢谢
发布于 2014-03-02 02:11:02
快速查看JSFL文档(pdf链接),您只有少数几个可用的属性:
Property Description
soundItem.bitRate A string that specifies the bit rate of a sound in the library. Available only for the MP3 compression type.
soundItem.bits A string that specifies the bits value for a sound in the library that has ADPCM compression.
soundItem.compressionType A string that specifies the compression type for a sound in the library.
soundItem.convertStereoToMono A Boolean value available only for MP3 and Raw compression types.
soundItem.fileLastModifiedDate Read-only; a string containing a hexadecimal number that represents the number of seconds that have elapsed between January 1, 1970, and the modification date of the original file (on disk) at the time the file was imported to the library.
soundItem.originalCompressionType Read-only; a string that specifies whether the specified item was imported as an MP3 file.
soundItem.quality A string that specifies the playback quality of a sound in the library. Available only for the MP3 compression type.
soundItem.sampleRate A string that specifies the sample rate for the audio clip.
soundItem.sourceFileExists Read-only; a Boolean value that specifies whether the file that was imported to the Library still exists in the location from where it was imported.
soundItem.sourceFileIsCurrent Read-only; a Boolean value that specifies whether the file modification date of the Library item is the same as the modification date on disk of the file that was imported.
soundItem.sourceFilePath Read-only; a string, expressed as a file:/// URI, that represents the path and name of the file that was imported into the Library.
soundItem.useImportedMP3Quality A Boolean value; if true, all other properties are ignored, and the imported MP3 quality is used目前,我只能想到两个版本中的一对workarounds...well:
FLfile.runCommandLine()调用命令行应用程序。一些命令行工具的例子是ffmpeg(例如ffmpeg -i yourAudioFile)或MediaInfo。我肯定还有其他人在那里。这取决于您需要使用什么操作系统,以及该工具是否可以轻松安装。理想情况下,您应该使用只输出持续时间的东西,但是如果您获得更多的数据,您应该能够解析输出并获得持续时间。还请注意,如果执行成功,该函数将返回1,否则将返回0,因此需要有一个命令,该命令还将将输出写入可以用jsfl读取的文本文件。
发布于 2016-01-03 12:34:43
如果您的音频文件是以恒定比特率编码的,则最终可以使用FLfile.getSize()方法获取文件的长度并计算其持续时间。
下面是一个jsfl片段,它计算并显示库中每个声音的帧持续时间:
var dom = fl.getDocumentDOM();
var lib = dom.library;
var soundsBitRate = 705;//specify here the bitrate of your files in Kbits/s
for (i = 0; i < lib.items.length; i++) {
if (lib.items[i].itemType == "sound") {
alert ("Duration of "+ lib.items[i].name + " : " + Math.ceil(FLfile.getSize(lib.items[i].sourceFilePath) / (soundsBitRate/8) / 1000 * dom.frameRate)+ " frames");
}
}https://stackoverflow.com/questions/22118871
复制相似问题