测试代码
local count = 0;
local audioHandle = audio.playSound("Test1.mp3", true)
print("audioHandle = ", audioHandle)
scheduler.scheduleGlobal(function()
count = count + 1;
print("count = ", count, audio.playSound("Test1.mp3", false))
end, 1)因为Test1是循环播放,一般认为会一直不停的播放。而在测试中当audio.playSound 播放32次时,也就是count等于32时,Test1的播放停止了。
测试打印结果
[LUA-print] audioHandle = 2464
[LUA-print] count = 1 2466
[LUA-print] count = 2 2467
[LUA-print] count = 3 2468
[LUA-print] count = 4 2469
[LUA-print] count = 5 2470
[LUA-print] count = 6 2471
[LUA-print] count = 7 2472
[LUA-print] count = 8 2473
[LUA-print] count = 9 2474
[LUA-print] count = 10 2475
[LUA-print] count = 11 2476
[LUA-print] count = 12 2477
[LUA-print] count = 13 2478
[LUA-print] count = 14 2479
[LUA-print] count = 15 2480
[LUA-print] count = 16 2481
[LUA-print] count = 17 2482
[LUA-print] count = 18 2483
[LUA-print] count = 19 2484
[LUA-print] count = 20 2485
[LUA-print] count = 21 2486
[LUA-print] count = 22 2487
[LUA-print] count = 23 2488
[LUA-print] count = 24 2489
[LUA-print] count = 25 2490
[LUA-print] count = 26 2491
[LUA-print] count = 27 2492
[LUA-print] count = 28 2493
[LUA-print] count = 29 2494
[LUA-print] count = 30 2495
[LUA-print] count = 31 2464
[LUA-print] count = 32 2465
[LUA-print] count = 33 2466
[LUA-print] count = 34 2467
[LUA-print] count = 35 2468
[LUA-print] count = 36 2469
[LUA-print] count = 37 2470audio句柄一直在 2464 到 2495 循环。通过查找发现这么一句,音效最大支持32个。看来最好还是不要用sound来播放循环音效。可能的话 还是用句柄来控制
//Tested source limit on 2.2.1 and 3.1.2 with up to 128 sources and appears to work. Older OS versions e.g 2.2 may support only 32
#define CD_SOURCE_LIMIT 32 //Total number of sources we will ever want, may actually get less
本文探讨了使用Lua脚本语言进行音效播放时遇到的问题,特别是在连续播放同一音效文件时,发现播放次数达到32次后即停止播放的现象。通过对测试代码及输出结果的分析,得出结论可能是由于系统对同时播放的音效数量有限制。
2191

被折叠的 条评论
为什么被折叠?



