Fix playing emoji animation sound in Safari
This commit is contained in:
parent
6cb38fb1cc
commit
1f7e1203fa
@ -1341,12 +1341,15 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o
|
|||||||
appStickersManager.preloadAnimatedEmojiStickerAnimation(emoji);
|
appStickersManager.preloadAnimatedEmojiStickerAnimation(emoji);
|
||||||
|
|
||||||
attachClickEvent(div, async(e) => {
|
attachClickEvent(div, async(e) => {
|
||||||
|
cancelEvent(e);
|
||||||
const animation = LottieLoader.getAnimation(div);
|
const animation = LottieLoader.getAnimation(div);
|
||||||
|
|
||||||
if(animation.paused) {
|
if(animation.paused) {
|
||||||
const doc = appStickersManager.getAnimatedEmojiSoundDocument(emoji);
|
const doc = appStickersManager.getAnimatedEmojiSoundDocument(emoji);
|
||||||
if(doc) {
|
if(doc) {
|
||||||
const audio = document.createElement('audio');
|
const audio = document.createElement('audio');
|
||||||
|
audio.style.display = 'none';
|
||||||
|
div.parentElement.append(audio);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await appDocsManager.downloadDoc(doc);
|
await appDocsManager.downloadDoc(doc);
|
||||||
@ -1355,9 +1358,10 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o
|
|||||||
audio.src = cacheContext.url;
|
audio.src = cacheContext.url;
|
||||||
audio.play();
|
audio.play();
|
||||||
await onMediaLoad(audio, undefined, true);
|
await onMediaLoad(audio, undefined, true);
|
||||||
|
|
||||||
audio.addEventListener('ended', () => {
|
audio.addEventListener('ended', () => {
|
||||||
audio.src = '';
|
audio.src = '';
|
||||||
|
audio.remove();
|
||||||
}, {once: true});
|
}, {once: true});
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|
||||||
@ -1368,8 +1372,6 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o
|
|||||||
animation.restart();
|
animation.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelEvent(e);
|
|
||||||
|
|
||||||
const doc = appStickersManager.getAnimatedEmojiSticker(emoji, true);
|
const doc = appStickersManager.getAnimatedEmojiSticker(emoji, true);
|
||||||
if(!doc) {
|
if(!doc) {
|
||||||
return;
|
return;
|
||||||
|
@ -182,15 +182,17 @@ export class AppStickersManager {
|
|||||||
flags: 0,
|
flags: 0,
|
||||||
id: sound.id,
|
id: sound.id,
|
||||||
access_hash: sound.access_hash,
|
access_hash: sound.access_hash,
|
||||||
attributes: [/* {
|
attributes: [{
|
||||||
_: 'documentAttributeAudio',
|
_: 'documentAttributeAudio',
|
||||||
duration: 1,
|
duration: 1,
|
||||||
pFlags: {}
|
pFlags: {
|
||||||
} */],
|
voice: true
|
||||||
|
}
|
||||||
|
}],
|
||||||
date: 0,
|
date: 0,
|
||||||
dc_id: rootScope.config.this_dc,
|
dc_id: rootScope.config.this_dc,
|
||||||
file_reference: bytes,
|
file_reference: bytes,
|
||||||
mime_type: 'audio/mp3',
|
mime_type: 'audio/ogg',
|
||||||
size: 1
|
size: 1
|
||||||
// size: 101010 // test loading everytime
|
// size: 101010 // test loading everytime
|
||||||
}, {
|
}, {
|
||||||
|
Loading…
Reference in New Issue
Block a user