mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-10-31 13:34:12 +00:00 
			
		
		
		
	* chore: add workflow which checks if SPDX ID exists * chore: add missing SPDX ID in some files * chore: change trigger condition * chore: trigger on push * lint
		
			
				
	
	
		
			14 lines
		
	
	
	
		
			580 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
	
		
			580 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /*
 | |
|  * SPDX-FileCopyrightText: syuilo and misskey-project
 | |
|  * SPDX-License-Identifier: AGPL-3.0-only
 | |
|  */
 | |
| 
 | |
| export default async function hasAudio(media: HTMLMediaElement) {
 | |
| 	const cloned = media.cloneNode() as HTMLMediaElement;
 | |
| 	cloned.muted = (cloned as typeof cloned & Partial<HTMLVideoElement>).playsInline = true;
 | |
| 	cloned.play();
 | |
| 	await new Promise((resolve) => cloned.addEventListener('playing', resolve));
 | |
| 	const result = !!(cloned as any).audioTracks?.length || (cloned as any).mozHasAudio || !!(cloned as any).webkitAudioDecodedByteCount;
 | |
| 	cloned.remove();
 | |
| 	return result;
 | |
| }
 |