首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在模态中设置默认音量

如何在模态中设置默认音量
EN

Stack Overflow用户
提问于 2021-05-27 20:45:03
回答 1查看 108关注 0票数 0

你好,我想知道为什么我不能设置我的音频在一个模式的默认值,以苗条。当我添加这一行时:audio.volume = 0.5;我的模式不再打开。以下是所有的模态组件:

代码语言:javascript
复制
<script>
    export let texte;
    export let clip;

    let audio = document.getElementById("aled");

    audio.volume = 0.5;
</script>

<style>
    body
    {
        -webkit-user-select: none; /* Safari */        
        -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* IE10+/Edge */
        user-select: none; /* Standard */
    }
    .clip
    {
        text-align: center;
    }
</style>
<body>
    <div class="clip">
        <audio id="aled" src={clip} controls></audio>
        <div>
            BLA BLA
            {texte}
        </div>
    </div>
</body>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-28 00:10:36

让我们让它更斯维特:

代码语言:javascript
复制
<script>
    import { onMount } from 'svelte';
    export let texte;
    export let clip;

    let audio;
    onMount(() => {
      // when the audio binding is ready set the volume
      audio.volume= 0.5;
    }) 
</script>

<style>
    body
    {
        -webkit-user-select: none; /* Safari */        
        -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* IE10+/Edge */
        user-select: none; /* Standard */
    }
    .clip
    {
        text-align: center;
    }
</style>
<body>
    <div class="clip">
        <audio bind:this={audio} src={clip} controls></audio>
        <div>
            BLA BLA
            {texte}
        </div>
    </div>
</body>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67729742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档