如何在 cocos2d ios 中播放 BGM 并知道当前播放时间? [英] How to play a BGM and know current playback time on in cocos2d ios?

查看:13
本文介绍了如何在 cocos2d ios 中播放 BGM 并知道当前播放时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款基于音乐的 IOS 游戏,需要在背景音乐和全局计时器之间严格同步,所以我正在寻找一种播放音乐的方式,同时知道音乐的确切位置每次更新帧时都在播放.

I'm working on a IOS game based on music, and a strict synchronize between background music and global timer is necessary, so I'm looking for some way to play music AND at the same time knowing which exact position the music is playing on at each frame update.

OALSimpleAudio 没有这种接口.有没有更好的解决方案?谢谢!

the OALSimpleAudio Doesn't have such kind of interface. Are there any better solution? Thank you!

推荐答案

OALSimpleAudio Background-Music (OALAudioTrack) 使用 AVAudioPlayer.

OALSimpleAudio Background-Music (OALAudioTrack) uses the AVAudioPlayer.

试试:

[[[[OALSimpleAudio sharedInstance] backgroundTrack] player] currentTime]

这篇关于如何在 cocos2d ios 中播放 BGM 并知道当前播放时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆