mirror of https://github.com/calzoneman/sync.git
Add disposal to audio switcher
This commit is contained in:
parent
008c24f892
commit
2cf26cdc4c
|
@ -477,7 +477,7 @@
|
||||||
audio.currentTime = time;
|
audio.currentTime = time;
|
||||||
};
|
};
|
||||||
function audioSwitchPlugin(options) {
|
function audioSwitchPlugin(options) {
|
||||||
const {audioElement, audioTracks, debugInterval, syncInterval, volume} = options;
|
const {audioElement, audioTracks, debugInterval, syncInterval, volume, handleDisposal} = options;
|
||||||
const player = this;
|
const player = this;
|
||||||
const checkAudioElement = () => {
|
const checkAudioElement = () => {
|
||||||
const videoElement = player.el_;
|
const videoElement = player.el_;
|
||||||
|
@ -533,6 +533,13 @@
|
||||||
audioTracks.forEach(track => audioTrackList.addTrack(new videojs.AudioTrack(track)));
|
audioTracks.forEach(track => audioTrackList.addTrack(new videojs.AudioTrack(track)));
|
||||||
audio.setAttribute('src', audioTracks[0].url);
|
audio.setAttribute('src', audioTracks[0].url);
|
||||||
}
|
}
|
||||||
|
player.on('dispose', () => {
|
||||||
|
this.audio.pause();
|
||||||
|
if(this.isOurAudio || handleDisposal){
|
||||||
|
this.audio.remove();
|
||||||
|
this.audioParent.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
player.on('play', () => {
|
player.on('play', () => {
|
||||||
syncTime(player, audio);
|
syncTime(player, audio);
|
||||||
if (audio.paused)
|
if (audio.paused)
|
||||||
|
|
Loading…
Reference in New Issue