我目前正在做一个项目,我需要显示一个以静音模式自动启动的 Dailymotion 视频。根据文档 - http://www.dailymotion.com/doc/api/sdk-javascript.html - DM.player 能够操纵视频的音量(方法:setMuted(muted))。但是,在对我的代码进行了多次更改之后,我无法弄清楚这是如何工作的。你以前做过吗?你能提供一些帮助吗?
谢谢
这是我的代码:
<html>
<head>
<script src="http://api.dmcdn.net/all.js"></script>
</head>
<body>
<div id="myPlayer"></div>
<script>
// This function init the player once the SDK is loaded
window.dmAsyncInit = function() {
// PARAMS is a javascript object containing parameters to pass to the player if any (eg: {autoplay: 1})
var player = DM.player("myPlayer", {video: "xz0ytt", width: "480", height: "270"});
// 4. We can attach some events on the player (using standard DOM events)
player.addEventListener("apiready", function(e) {
// alert(e.target.muted);
// e.target.muted = true;
// alert(e.target.muted);
// e.target.play();
// player.setMuted(1);
player.setMuted("1");
e.target.play();
});
};
</script>
</body>
</html>