mirror of https://github.com/axmolengine/axmol.git
Merge pull request #15619 from VisualSJ/v3_audio
audio search path (android)
This commit is contained in:
commit
9c0acf1e5d
|
@ -2626,6 +2626,26 @@ _p.setDisabledSpriteFrame = function(frame) {
|
|||
cc.MenuItemToggle.prototype.selectedItem = cc.MenuItemToggle.prototype.getSelectedItem;
|
||||
|
||||
|
||||
// playMusic searchPaths
|
||||
if (cc.sys.os === cc.sys.OS_ANDROID && cc.audioEngine) {
|
||||
cc.audioEngine._playMusic = cc.audioEngine.playMusic;
|
||||
cc.audioEngine.playMusic = function () {
|
||||
var args = arguments;
|
||||
var searchPaths = jsb.fileUtils.getSearchPaths();
|
||||
var path = args[0];
|
||||
searchPaths.some(function (item) {
|
||||
var temp = item + '/' + path;
|
||||
var exists = jsb.fileUtils.isFileExist(temp);
|
||||
if (exists) {
|
||||
path = temp;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
args[0] = path;
|
||||
cc.audioEngine._playMusic.apply(cc.audioEngine, args);
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// LabelTTF API wrappers
|
||||
//
|
||||
|
|
|
@ -232,9 +232,6 @@ var soundId = null;
|
|||
var playMusic = function () {
|
||||
cc.log("play background music");
|
||||
var musicFile = MUSIC_FILE;
|
||||
if (cc.sys.os == cc.sys.OS_ANDROID) {
|
||||
musicFile = "res/"+musicFile;
|
||||
}
|
||||
audioEngine.playMusic(musicFile, false);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue