Cocos2dx引擎版本:3.17.2
路径:..\cocos\audio\include\SimpleAudioEngine.h?添加方法声明
virtual void setMusicCurrentTime(int curMTime);//单位是毫秒
virtual int getMusicCurrentTime();
virtual int getMusicDuration();
?Android端
路径:..\cocos\audio\android\cddSimpleAudioEngine.cpp
void SimpleAudioEngine::setMusicCurrentTime(int curMTime) { }
int SimpleAudioEngine::getMusicCurrentTime() { }
int SimpleAudioEngine::getMusicDuration() { }
?路径:..\cocos\audio\android\jni\cddandroidAndroidJavaEngine.h
virtual void setMusicCurrentTime(int curMTime);
virtual int getMusicCurrentTime();
virtual int getMusicDuration();
路径:..\cocos\audio\android\jni\cddandroidAndroidJavaEngine.cpp
void AndroidJavaEngine::setMusicCurrentTime(int curMTime)
{
JniHelper::callStaticVoidMethod(helperClassName, "setMusicCurrentTime", curMTime);
}
int AndroidJavaEngine::getMusicCurrentTime()
{
return JniHelper::callStaticIntMethod(helperClassName, "getMusicCurrentTime");
}
int AndroidJavaEngine::getMusicDuration()
{
return JniHelper::callStaticIntMethod(helperClassName, "getMusicDuration");
}
路径:..\proj.android\cocos2dx\java\src\org\cocos2dx\lib\Cocos2dxMusic.java
public void setMusicCurrentTime(int curMTime)
{
this.mBackgroundMediaPlayer.seekTo(curMTime);
}
public long getMusicCurrentTime()
{
return this.mBackgroundMediaPlayer.getCurrentPosition();
}
public long getMusicDuration()
{
return this.mBackgroundMediaPlayer.getDuration();
}
路径:..\proj.android\cocos2dx\java\src\org\cocos2dx\lib\Cocos2dxHelper.java
public static void setMusicCurrentTime(int curMTime)
{
Cocos2dxHelper.sCocos2dMusic.setMusicCurrentTime(curMTime);
}
public static int getMusicCurrentTime()
{
return Cocos2dxHelper.sCocos2dMusic.getMusicCurrentTime();
}
public static int getMusicDuration()
{
return Cocos2dxHelper.sCocos2dMusic.getMusicDuration();
}
|