【问题标题】:ActionScript 3 Error when dynamically playing audio动态播放音频时出现 ActionScript 3 错误
【发布时间】:2015-02-06 16:55:01
【问题描述】:

我正在为 Air iOS 编写游戏。我有一个音频文件,与我的 .fla 文件保存在同一目录中。这是我用来播放它的代码:

import flash.net.URLRequest;

var snd:Sound = new Sound(new  URLRequest("507560_-BlastProcess-.mp3")); 
snd.play(0, 40);

这是我在 Air Debug Launcher 中测试时遇到的错误:

[SWF] Spike%20Jungle.swf - 72668 bytes after decompression
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
    at SpikeJungle_fla::MainTimeline/frame1()[SpikeJungle_fla.MainTimeline::frame1:128]
    at runtime::ContentPlayer/loadInitialContent()
    at runtime::ContentPlayer/playRawContent()
    at runtime::ContentPlayer/playContent()
    at runtime::AppRunner/run()
    at ADLAppEntry/run()
    at global/runtime::ADLEntry()
[UnloadSWF] Spike%20Jungle.swf
Test Movie terminated.

我该如何解决这个问题?

【问题讨论】:

  • MainTimeLine 类的第 128 行是什么?
  • StreamError - 要么是找不到文件,要么是安全限制,或者您正在尝试播放未完全加载的文件 - 不能确定,也许可以立即开始播放,但我会先等待加载程序触发 Event.COMPLETE 然后才开始播放。
  • @AndreiNikolaenko 我试过这个:import flash.events.Event; import flash.media.Sound; import flash.net.URLRequest; var s:Sound = new Sound(); s.addEventListener(Event.COMPLETE, onSoundLoaded); var req:URLRequest = new URLRequest("HexagonForce.mp3"); s.load(req); function onSoundLoaded(event:Event):void { var localSound:Sound = event.target as Sound; localSound.play(); } 但我仍然得到同样的错误。
  • 那我就没主意了。也许声音文件本身已损坏,无法读取?

标签: actionscript-3 flash actionscript air


【解决方案1】:

要么需要跨域,要么文件路径不正确。

您的 AIR 应用程序可能与您的 mp3 不在同一个文件夹中运行。查看已编译的 air 应用程序的存储位置并将 mp3 移动到该文件夹​​。

http://www.judahfrangipane.com/blog/2007/02/15/error-2032-stream-error/

您可能还想使用 SoundChannel 来停止声音

【讨论】:

    猜你喜欢
    • 2022-08-23
    • 1970-01-01
    • 1970-01-01
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多