How to play a BGM and know current playback time on in cocos2d ios?(如何在 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 并知道当前播放时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 cocos2d ios 中播放 BGM 并知道当前播放时间?
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
