nvminhtu / LearnPhaser

Tutorial, Experience, Coding with Phraser
1 stars 2 forks source link

[Audio] Lỗi audio không chạy trên thiết bị android version cũ #54

Open nvminhtu opened 7 years ago

nvminhtu commented 7 years ago

https://gist.github.com/fcingolani/9176aed13701f9a0f55d Đang test cách này nha anh em @lamanhdai @thanhtungtnt

nvminhtu commented 7 years ago

`Phaser.SoundManager.prototype._play = Phaser.SoundManager.prototype.play; Phaser.SoundManager.prototype.play = function (key, volume, loop) {

if(this.game.device.cordova){
    window.plugins.NativeAudio.play(key);
}else{
    return this._play(key, volume, loop);
}

}

Phaser.Loader.prototype._loadAudioTag = Phaser.Loader.prototype.loadAudioTag; Phaser.Loader.prototype.loadAudioTag = function (file) {

if(this.game.device.cordova){

    var _this = this;

    window.plugins.NativeAudio.preloadSimple( file.key, this.transformUrl(file.url, file), function(){
        _this.fileComplete(file);
    }, function(){
        _this.fileError(file);
    });

}else{

    this._loadAudioTag(file);

}

}`