mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:03:09 +08:00
Merge pull request #1441 from VisualSJ/v1.4-audioVolume
Fixed a bug about ios setVolume
This commit is contained in:
@@ -269,6 +269,12 @@ var WebAudioElement = function (buffer, audio) {
|
||||
this.playedLength = 0;
|
||||
|
||||
this._currextTimer = null;
|
||||
|
||||
this._endCallback = function () {
|
||||
if (this.onended) {
|
||||
this.onended(this);
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
(function (proto) {
|
||||
@@ -313,11 +319,7 @@ var WebAudioElement = function (buffer, audio) {
|
||||
|
||||
this._currentSource = audio;
|
||||
|
||||
audio.onended = function () {
|
||||
if (this.onended) {
|
||||
this.onended(this);
|
||||
}
|
||||
}.bind(this);
|
||||
audio.onended = this._endCallback;
|
||||
|
||||
// If the current audio context time stamp is 0
|
||||
// There may be a need to touch events before you can actually start playing audio
|
||||
@@ -374,8 +376,9 @@ var WebAudioElement = function (buffer, audio) {
|
||||
proto.__defineGetter__('volume', function () { return this._volume['gain'].value; });
|
||||
proto.__defineSetter__('volume', function (num) {
|
||||
this._volume['gain'].value = num;
|
||||
if (cc.sys.os === cc.sys.OS_IOS && !this.paused) {
|
||||
if (cc.sys.os === cc.sys.OS_IOS && !this.paused && this._currentSource) {
|
||||
// IOS must be stop webAudio
|
||||
this._currentSource.onended = null;
|
||||
this.pause();
|
||||
this.play();
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ var AudioSource = cc.Class({
|
||||
return this._volume;
|
||||
},
|
||||
set: function (value) {
|
||||
value = cc.clamp01(value);
|
||||
this._volume = value;
|
||||
var audio = this.audio;
|
||||
if (audio && !this._mute) {
|
||||
|
||||
Reference in New Issue
Block a user