Fix audio & video simultaneous play
This commit is contained in:
parent
ee83d17028
commit
dbd82645da
@ -9,6 +9,8 @@ class AppAudio {
|
|||||||
private audios: {[mid: string]: HTMLAudioElement} = {};
|
private audios: {[mid: string]: HTMLAudioElement} = {};
|
||||||
private playingAudio: HTMLAudioElement;
|
private playingAudio: HTMLAudioElement;
|
||||||
|
|
||||||
|
public willBePlayedAudio: HTMLAudioElement;
|
||||||
|
|
||||||
private prevMid: number;
|
private prevMid: number;
|
||||||
private nextMid: number;
|
private nextMid: number;
|
||||||
|
|
||||||
@ -109,7 +111,7 @@ class AppAudio {
|
|||||||
this.addAudio(message.media.document, mid);
|
this.addAudio(message.media.document, mid);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('loadSiblingsAudio', audio, type, mid, value, this.prevMid, this.nextMid);
|
//console.log('loadSiblingsAudio', audio, type, mid, value, this.prevMid, this.nextMid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +124,15 @@ class AppAudio {
|
|||||||
this.playingAudio.pause();
|
this.playingAudio.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public pause() {
|
||||||
|
if(!this.playingAudio || this.playingAudio.paused) return;
|
||||||
|
this.playingAudio.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
public willBePlayed(audio: HTMLAudioElement) {
|
||||||
|
this.willBePlayedAudio = audio;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const appAudio = new AppAudio();
|
const appAudio = new AppAudio();
|
||||||
|
@ -393,6 +393,8 @@ export default class AudioElement extends HTMLElement {
|
|||||||
const r = () => {
|
const r = () => {
|
||||||
onLoad();
|
onLoad();
|
||||||
|
|
||||||
|
appAudio.willBePlayed(this.audio); // prepare for loading audio
|
||||||
|
|
||||||
if(!preloader) {
|
if(!preloader) {
|
||||||
preloader = new ProgressivePreloader(null, false);
|
preloader = new ProgressivePreloader(null, false);
|
||||||
}
|
}
|
||||||
@ -405,7 +407,14 @@ export default class AudioElement extends HTMLElement {
|
|||||||
else this.addAudioListener('canplay', resolve);
|
else this.addAudioListener('canplay', resolve);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
downloadDiv.remove();
|
downloadDiv.remove();
|
||||||
this.audio.play();
|
|
||||||
|
//setTimeout(() => {
|
||||||
|
// release loaded audio
|
||||||
|
if(appAudio.willBePlayedAudio == this.audio) {
|
||||||
|
this.audio.play();
|
||||||
|
appAudio.willBePlayedAudio = null;
|
||||||
|
}
|
||||||
|
//}, 10e3);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,8 +105,6 @@ class AppDocsManager {
|
|||||||
if(!apiDoc.mime_type) {
|
if(!apiDoc.mime_type) {
|
||||||
switch(apiDoc.type) {
|
switch(apiDoc.type) {
|
||||||
case 'gif':
|
case 'gif':
|
||||||
apiDoc.mime_type = 'video/mp4';
|
|
||||||
break;
|
|
||||||
case 'video':
|
case 'video':
|
||||||
case 'round':
|
case 'round':
|
||||||
apiDoc.mime_type = 'video/mp4';
|
apiDoc.mime_type = 'video/mp4';
|
||||||
|
@ -12,6 +12,7 @@ import AvatarElement from "../../components/avatar";
|
|||||||
import LazyLoadQueue from "../../components/lazyLoadQueue";
|
import LazyLoadQueue from "../../components/lazyLoadQueue";
|
||||||
import appForward from "../../components/appForward";
|
import appForward from "../../components/appForward";
|
||||||
import { isSafari, mediaSizes } from "../config";
|
import { isSafari, mediaSizes } from "../config";
|
||||||
|
import appAudio from "../../components/appAudio";
|
||||||
|
|
||||||
export class AppMediaViewer {
|
export class AppMediaViewer {
|
||||||
public wholeDiv = document.querySelector('.media-viewer-whole') as HTMLDivElement;
|
public wholeDiv = document.querySelector('.media-viewer-whole') as HTMLDivElement;
|
||||||
@ -795,6 +796,10 @@ export class AppMediaViewer {
|
|||||||
div.append(video);
|
div.append(video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix for simultaneous play
|
||||||
|
appAudio.pause();
|
||||||
|
appAudio.willBePlayedAudio = null;
|
||||||
|
|
||||||
const player = new VideoPlayer(video, true, media.supportsStreaming);
|
const player = new VideoPlayer(video, true, media.supportsStreaming);
|
||||||
return player;
|
return player;
|
||||||
/* player.wrapper.parentElement.append(video);
|
/* player.wrapper.parentElement.append(video);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user