我的 Flash 应用程序具有以下代码。在本地测试时会播放声音,但在 iOS 上发布时不会播放。
mp3 文件在 components/sound 目录下,该目录通过 Adobe Flash cs6 professional 中的 Air iOS3.6 发布设置包含。
我做了一些测试,虽然 mp3 文件和目录在 iOS 中存在(使用 File.exists 测试),但 sound.bytesLoaded 显示 0 值。在本地测试时,它显示实际文件大小。
谁能帮我解决这个问题?
var path= File.applicationDirectory.resolvePath("components/sound/click.mp3").nativePath;
var sound = new Sound(new URLRequest(path));
sound.play();
[编辑]
当我简单地将 new URLRequest(path) 替换为 new URLRequest("components/sound/click.mp3") 时它起作用了。
但是,如果有人能解释为什么前一个 (nativePath) 不起作用,我将不胜感激。
最佳答案
阅读 this thread on Adobe Community forums关于在 iOS 上加载外部声音,您的代码似乎没问题,我看到的唯一可疑之处是您应该以“/”开头的文件路径,例如:
var path= File.applicationDirectory.resolvePath("/components/sound/click.mp3").nativePath;
希望这对您有所帮助!
关于ios - Air iOS,Flash Pro,外接mp3无法播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14836744/