如何动态更改HTML上的媒体音量

时间:2018-10-25 09:53:23

标签: html angularjs html5-audio

我有音量设置和声音设置表格,配置的设置将保存到数据库库中。现在,我要在我的<video>上加载已保存的音量设置。我尝试使用onloadstart="this.volume=0.1"并将值0.1更改为保存在数据库中的值,所以我这样做是这样的:

//d.volume is the number or amount of volume that I saved on database
<video onloadstart="this.volume={{d.volume}}">
<source src="Media/myvideo.mp4" type="video/mp4">
</video>

但我收到此错误:

[$compile:nodomevents] Interpolations for HTML DOM event attributes are disallowed. Please use the ng- versions (such as ng-click instead of onclick) instead.

我还尝试了以下代码:

//This is the Template
<video id="myvideo">
<source src="Media/myvideo.mp4" type="video/mp4">
</video>

//This is the Controller
var vid = document.getElementById("myvideo");
var volume = savedvolumesetup //This is the number or amount of volume that I saved on database
vid.volume = volume;

但是,我仍然没有走错的错误。希望你能帮助我,我是新手。

0 个答案:

没有答案