work around opus bug
This commit is contained in:
@@ -79,8 +79,16 @@
|
||||
let volumeBar = $state();
|
||||
let innerWidth = $state();
|
||||
let innerHeight = $state();
|
||||
let isSafari = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
// work around coreaudio bug
|
||||
// see https://git.webbieweb.org/apt-get/strimserve/issues/1
|
||||
const ua = navigator.userAgent;
|
||||
const isIOS = /iPad|iPhone|iPod/.test(ua);
|
||||
const isDesktopSafari = /Safari/.test(ua) && !/Chrome/.test(ua) && !/Chromium/.test(ua);
|
||||
isSafari = isIOS || isDesktopSafari;
|
||||
|
||||
// default volume
|
||||
const volumeData = localStorage.getItem('volume');
|
||||
volume = volumeData ? parseFloat(volumeData) : 0.67;
|
||||
@@ -300,8 +308,13 @@
|
||||
onended={bubble('ended')}
|
||||
{preload}
|
||||
>
|
||||
<source {src} type="audio/ogg;codecs=opus" />
|
||||
<source src="{src}.mp3" type="audio/mpeg" />
|
||||
{#if isSafari}
|
||||
<source src="{src}.mp3" type="audio/mpeg" />
|
||||
<source {src} type="audio/ogg;codecs=opus" />
|
||||
{:else}
|
||||
<source {src} type="audio/ogg;codecs=opus" />
|
||||
<source src="{src}.mp3" type="audio/mpeg" />
|
||||
{/if}
|
||||
</audio>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user