10000 fix webaduio.setTargetTime on crosswalk by PPpro · Pull Request #5281 · cocos/cocos-engine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix webaduio.setTargetTime on crosswalk #5281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions cocos2d/audio/CCAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,9 @@ let WebAudioElement = function (buffer, audio) {
this._buffer = buffer;

this._gainObj = this._context['createGain']();
this._volume = 1;
// https://www.chromestatus.com/features/5287995770929152
if (this._gainObj['gain'].setTargetAtTime) {
this._gainObj['gain'].setTargetAtTime(this._volume, this._context.currentTime, TIME_CONSTANT);
} else {
this._gainObj['gain'].value = 1;
}
this._gainObj['connect'](this._context['destination']);
this.volume = 1;

this._gainObj['connect'](this._context['destination']);
this._loop = false;
// The time stamp on the audio time axis when the recording begins to play.
this._startTime = -1;
Expand Down Expand Up @@ -503,18 +497,26 @@ let WebAudioElement = function (buffer, audio) {
},
set: function (num) {
this._volume = num;
if (this._gainObj['gain'].setTargetAtTime) {
this._gainObj['gain'].setTargetAtTime(this._volume, this._context.currentTime, TIME_CONSTANT);
} else {
this._volume['gain'].value = num;
// https://www.chromestatus.com/features/5287995770929152
if (this._gainObj.gain.setTargetAtTime) {
try {
this._gainObj.gain.setTargetAtTime(num, this._context.currentTime, TIME_CONSTANT);
}
catch (e) {
// Some other unknown browsers may crash if TIME_CONSTANT is 0
this._gainObj.gain.setTargetAtTime(num, this._context.currentTime, 0.01);
}
}
else {
this._gainObj.gain.value = num;
}

if (sys.os === sys.OS_IOS && !this.paused && this._currentSource) {
// IOS must be stop webAudio
this._currentSource.>
this.pause();
this.play();
}
return num;
},
enumerable: true,
configurable: true
Expand Down
0