mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
web audio can't play twice (#5869)
This commit is contained in:
@@ -66,6 +66,7 @@ export class AudioPlayerWeb extends AudioPlayer {
|
||||
};
|
||||
|
||||
this._do_play = () => {
|
||||
this._state = PlayingState.PLAYING;
|
||||
this._sourceNode = this._context.createBufferSource();
|
||||
this._sourceNode.buffer = this._audio;
|
||||
this._sourceNode.loop = this._loop;
|
||||
@@ -75,7 +76,6 @@ export class AudioPlayerWeb extends AudioPlayer {
|
||||
cc.director.once(cc.Director.EVENT_AFTER_UPDATE, () => {
|
||||
this._sourceNode.start(0, this._offset);
|
||||
this._eventTarget.emit('started');
|
||||
this._state = PlayingState.PLAYING;
|
||||
});
|
||||
/* still not supported by all platforms *
|
||||
this._sourceNode.onended = this._on_ended;
|
||||
|
||||
Reference in New Issue
Block a user