简体   繁体   English

openfl-音频在cpp目标上不起作用

[英]openfl - audio doesn't work on cpp target

I've added <assets path="assets/audio" rename="audio" /> to the application.xml file. 我已经将<assets path="assets/audio" rename="audio" />到application.xml文件中。

And I load the "mp3" files in the audio folder by calling Assets.getSound("2_3_1.mp3"); 然后我通过调用Assets.getSound("2_3_1.mp3");将“ mp3”文件加载到音频文件夹中Assets.getSound("2_3_1.mp3"); , and then use the .play(); ,然后使用.play(); method on that (sound) object to play the file. (声音)对象上的方法播放文件。

The sounds play in flash target. 声音在flash目标中播放。 But don't play on cpp targets. 但是不要在cpp目标上玩。 I'm mainly targeting Android (cpp) and iOS (c#) targets for my app. 我主要针对我的应用定位Android(cpp)和iOS(c#)目标。

When debugging for windows (cpp) target, it shows these errors in console: 调试windows (cpp)目标时,它将在控制台中显示以下错误:

Sound.hx:99: Error: Could not load "audio/2_3_1.mp3"
Error opening sound file, unsupported type.
Error opening sound data
Done(0)

I believe mp3 isn't supported on Windows and most other targets due a decision related to licensing costs for the format. 我认为Windows和大多数其他目标不支持mp3,这是因为与该格式的许可费用有关的决定。

The Flash target is an exception since Adobe has an agreement that allows developers to use the format without paying royalties. Flash目标是一个例外,因为Adobe达成了一项协议,允许开发人员使用该格式而无需支付专利使用费。 This is discussed more here: http://www.openfl.org/blog/2013/09/18/to-mp3-or-not-to-mp3/ 在此处进行更多讨论: http : //www.openfl.org/blog/2013/09/18/to-mp3-or-not-to-mp3/

A workaround is to use the .ogg format for non-Flash platforms for audio, and include the audio files for each platform by specifying the asset paths in your Project.xml eg: 一种解决方法是对非Flash平台使用.ogg格式的音频,并通过在Project.xml中指定资产路径来包括每个平台的音频文件,例如:

<assets path="assets/music" type="music" if="flash"> <!-- mp3s --> </assets> <assets path="assets/music" type="music" unless="flash"> <!-- oggs --> </assets>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM