Merge pull request #15619 from VisualSJ/v3_audio

audio search path (android)
This commit is contained in:
minggo 2016-05-19 18:06:58 +08:00
commit 9c0acf1e5d
2 changed files with 20 additions and 3 deletions

View File

@ -2626,6 +2626,26 @@ _p.setDisabledSpriteFrame = function(frame) {
cc.MenuItemToggle.prototype.selectedItem = cc.MenuItemToggle.prototype.getSelectedItem; 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 // LabelTTF API wrappers
// //

View File

@ -232,9 +232,6 @@ var soundId = null;
var playMusic = function () { var playMusic = function () {
cc.log("play background music"); cc.log("play background music");
var musicFile = MUSIC_FILE; var musicFile = MUSIC_FILE;
if (cc.sys.os == cc.sys.OS_ANDROID) {
musicFile = "res/"+musicFile;
}
audioEngine.playMusic(musicFile, false); audioEngine.playMusic(musicFile, false);
}; };