Cocos2dx-lua 播放音循环播放问题

测试代码

		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	2470
audio句柄一直在 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


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值