flash - 如何使用JSFL查找音频剪辑的长度

标签 flash audio jsfl

我希望有人可以帮助我。
我遇到需要将音频文件添加到已经开发的FLA文件中的情况。
为此,我必须打开fla文件,创建一个新层,将音频片段拖到该层,将所有层延伸到音频片段的末尾,然后添加一个停止点。

我希望使用JSFL为我做到这一点。
我目前拥有它,可以在库中选择一个音频剪辑,然后运行我的JSFL脚本。
我将声音剪辑添加到新图层。
它创建另一个图层,并在最后一帧添加停止点。
我还可以扩展所有图层,但要扩展很多框架。
我的问题是我似乎无法弄清楚如何获得声音片段的长度,因此我知道扩展所有层的长度。

任何帮助都会很棒。

谢谢

最佳答案

快速浏览JSFL documentation(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

目前,我只能想到一些棘手的解决方法...两个版本中的一个:
  • 可以让导出声音的人员导出与声音同名的.txt,其中包含声音的长度。您可以使用FLfile加载和读取此文件,然后使用文档的帧速率,计算所需的帧数
  • 与上述方法类似,您可以拨出一个命令行工具,其唯一目的是输出音频文件的长度(使用声音的sourceFilePath属性)或使用现有的工具(*)。您可以使用未记录的FLfile.runCommandLine()调用命令行应用程序。

  • 命令行工具的一些示例是ffmpeg(例如ffmpeg -i yourAudioFile)或MediaInfo。我确定那里还有其他人。这取决于您需要使用的操作系统以及该工具是否易于安装。理想情况下,您将使用仅输出持续时间的内容,但是如果您获得更多数据,则应该能够解析输出并获取持续时间。还要注意,该函数将返回1以成功执行,否则返回0,因此您将需要一个将输出也写入文本文件的命令,您可以使用jsfl读取该文件。

    关于flash - 如何使用JSFL查找音频剪辑的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22118871/

    相关文章:

    .net - KB3132372导致dotnet嵌入式浏览器控件在包含Flash的网站上崩溃

    actionscript-3 - As3Iso : Why use a secondary display list?

    javascript - 使用 Javascript 中的 JSFL 脚本返回值

    flash - 如何使用 JSFL 设置影片剪辑的舞台实例名称

    flash - HTML5 canvas 是否能够像 Flash 这样丰富复杂的游戏?

    flash - 为什么从 Flash 调用 Google Analytics 事件跟踪并调用 getURL (_blank) 会停止返回 __utm.gif?

    Android:如何访问音频文件?

    iphone - 为什么我的录音无法播放? (iPhone SDK)

    swift - 铃声音量 slider ,快速

    javascript - 如何听Flash pro Action ?