如何通过javascript静音文档声音

时间:2016-06-16 12:36:37

标签: javascript html audio

我使用的广告代码每隔3分钟<iframe>播放一部电影

这听起来很恼人的用户,我怎么能把它静音,

由于<iframe>

,我无法在CROSS-ORIGIN身体中进行更改

有解决方案吗?

选择来源:

<div data-asm-done="1" class="asm_async_creative" data-asm-host="xxlmarketingsolution.adspirit.de" data-asm-params="pid=1" id="asmvi1" style="position:relative; width:610px; height:343px;">
<script src="//xxlmarketingsolution.adspirit.de/adscript.php?async=asmvi1&amp;wpcn=asm29334x1466076618999&amp;ref=http%3A%2F%2Ftv.spielenxxl.de%2F&amp;swf=21&amp;scx=1920&amp;scy=1080&amp;vis=4&amp;tz=1466076619000&amp;pid=1"></script><ins id="asm_fls36x7558266y1466076621" style="display: inline-block; width: 610px; height: 343px; text-align: left;" class=""><span id="asmspan_vastwrapper5192281" style="font-size: 1px; width: 1px; height: 1px; overflow: hidden; display: inline-block;" class="asm_flash"><object data="http://cdn.adspirit.de/banner/advastwrapper.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=21,0,0,0" id="adspiritflashvastwrapper5192281" type="application/x-shockwave-flash" height="1" width="1"> <param name="movie" value="http://cdn.adspirit.de/banner/advastwrapper.swf"> <param name="flashvars" value="path=http%3A%2F%2Fvideo-adserver.ibillboard.com%2FgetAd%3Ftagid%3Dee7891f6-4cc8-4155-d266-c2a0df3f0d65&amp;id=adspiritflashvastwrapper5192281&amp;player_id=adspiritflashvastwrapper5192281">  <param name="quality" value="autohigh">  <param name="transparency" value="yes">  <param name="allowFullScreen" value="true">  <param name="allowScriptAccess" value="always">  <param name="allowNetworking" value="all">  <param name="wmode" value="transparent">  <param name="swLiveConnect" value="true">  <embed src="http://cdn.adspirit.de/banner/advastwrapper.swf" flashvars="path=http%3A%2F%2Fvideo-adserver.ibillboard.com%2FgetAd%3Ftagid%3Dee7891f6-4cc8-4155-d266-c2a0df3f0d65&amp;id=adspiritflashvastwrapper5192281&amp;player_id=adspiritflashvastwrapper5192281" allownetworking="all" allowfullscreen="true" allowscriptaccess="always" name="adspiritflashvastwrapper5192281" transperency="yes" swliveconnect="true" quality="autohigh" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent" menu="false" height="1" width="1"> </object></span><span id="asmspan_5192281_vpaid" style="font-size: 1px; width: 1px; height: 1px; overflow: hidden; display: none;" class="asm_flash"><object data="http://cdn.adspirit.de/banner/advpaid.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=21,0,0,0" id="adspiritflash5192281_vpaid" type="application/x-shockwave-flash" height="343" width="610"> <param name="movie" value="http://cdn.adspirit.de/banner/advpaid.swf"> <param name="flashvars" value="wmode=opaque&amp;id=adspiritflash5192281_vpaid&amp;player_id=adspiritflash5192281_vpaid">  <param name="quality" value="autohigh">  <param name="transparency" value="yes">  <param name="allowFullScreen" value="true">  <param name="allowScriptAccess" value="always">  <param name="allowNetworking" value="all">  <param name="wmode" value="opaque">  <param name="swLiveConnect" value="true">  <embed src="http://cdn.adspirit.de/banner/advpaid.swf" flashvars="wmode=opaque&amp;id=adspiritflash5192281_vpaid&amp;player_id=adspiritflash5192281_vpaid" allownetworking="all" allowfullscreen="true" allowscriptaccess="always" name="adspiritflash5192281_vpaid" transperency="yes" swliveconnect="true" quality="autohigh" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque" menu="false" height="343" width="610"> </object></span><script src="http://cdn.adspirit.de/banner/vastwrapper_async.js" type="text/javascript"></script><script src="http://cdn.adspirit.de/banner/vast_async.js" type="text/javascript"></script></ins><span id="asmspan_5192281" style="font-size: 1px; overflow: hidden; width: 610px; height: 343px; position: absolute; left: 0px; top: 0px; z-index: 991919991; display: inline-block;" class="asm_flash"><object data="http://cdn.adspirit.de/banner/admovie.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=21,0,0,0" id="adspiritflash5192281" type="application/x-shockwave-flash" height="343" width="610"> <param name="movie" value="http://cdn.adspirit.de/banner/admovie.swf"> <param name="flashvars" value="&amp;movie=http%3A%2F%2Fcdn.adspirit.de%2Fbanner%2F1x1.flv&amp;clickurl=http%3A%2F%2Fxxlmarketingsolution.adspirit.de%2Fadclick.php%3Ftz%3D1466076621131449%3Bpid%3D1%3Bkid%3D30%3Bwmid%3D36%3Bwsid%3D4%3Buid%3D1%3Bord%3D1466076621&amp;&amp;fgcolor=0xFFFFFF&amp;bgcolor=0xFFFFFF&amp;txcolor=0xFFFFFF&amp;volume=25&amp;&amp;MouseMovePlay=off&amp;autoload=on&amp;mute=off&amp;MouseMoveSound=off&amp;FLVmenu=off&amp;autorewind=off&amp;loop=off&amp;muteonly=off&amp;MuteButton=on&amp;FLVzoom=on&amp;FullscreenButton=off&amp;runtime=off&amp;MouseOutMute=off&amp;replay=off&amp;volumebar=on&amp;PlayButton=off&amp;clicktarget=_blank&amp;clickJSFunction=window.plyr_5192281_click&amp;stopJSFunction=window.plyr_5192281_stop&amp;playJSFunction=window.plyr_5192281_play&amp;timeJSFunction=window.plyr_5192281_time&amp;pauseJSFunction=window.plyr_5192281_pause&amp;errorJSFunction=window.plyr_5192281_error&amp;rewindJSFunction=window.plyr_5192281_rewind&amp;expandJSFunction=window.plyr_5192281_expand&amp;collapseJSFunction=window.plyr_5192281_collapse&amp;finishJSFunction=window.plyr_5192281_finish&amp;volumeChangeJSFunction=window.plyr_5192281_volume&amp;liveConnectName=adspiritflash5192281&amp;positionJSFunction=window.plyr_5192281_getPos&amp;&amp;id=adspiritflash5192281&amp;player_id=adspiritflash5192281">  <param name="quality" value="autohigh">  <param name="transparency" value="yes">  <param name="allowFullScreen" value="true">  <param name="allowScriptAccess" value="always">  <param name="allowNetworking" value="all">  <param name="wmode" value="transparent">  <param name="swLiveConnect" value="true">  <embed src="http://cdn.adspirit.de/banner/admovie.swf" flashvars="&amp;movie=http%3A%2F%2Fcdn.adspirit.de%2Fbanner%2F1x1.flv&amp;clickurl=http%3A%2F%2Fxxlmarketingsolution.adspirit.de%2Fadclick.php%3Ftz%3D1466076621131449%3Bpid%3D1%3Bkid%3D30%3Bwmid%3D36%3Bwsid%3D4%3Buid%3D1%3Bord%3D1466076621&amp;&amp;fgcolor=0xFFFFFF&amp;bgcolor=0xFFFFFF&amp;txcolor=0xFFFFFF&amp;volume=25&amp;&amp;MouseMovePlay=off&amp;autoload=on&amp;mute=off&amp;MouseMoveSound=off&amp;FLVmenu=off&amp;autorewind=off&amp;loop=off&amp;muteonly=off&amp;MuteButton=on&amp;FLVzoom=on&amp;FullscreenButton=off&amp;runtime=off&amp;MouseOutMute=off&amp;replay=off&amp;volumebar=on&amp;PlayButton=off&amp;clicktarget=_blank&amp;clickJSFunction=window.plyr_5192281_click&amp;stopJSFunction=window.plyr_5192281_stop&amp;playJSFunction=window.plyr_5192281_play&amp;timeJSFunction=window.plyr_5192281_time&amp;pauseJSFunction=window.plyr_5192281_pause&amp;errorJSFunction=window.plyr_5192281_error&amp;rewindJSFunction=window.plyr_5192281_rewind&amp;expandJSFunction=window.plyr_5192281_expand&amp;collapseJSFunction=window.plyr_5192281_collapse&amp;finishJSFunction=window.plyr_5192281_finish&amp;volumeChangeJSFunction=window.plyr_5192281_volume&amp;liveConnectName=adspiritflash5192281&amp;positionJSFunction=window.plyr_5192281_getPos&amp;&amp;id=adspiritflash5192281&amp;player_id=adspiritflash5192281" allownetworking="all" allowfullscreen="true" allowscriptaccess="always" name="adspiritflash5192281" transperency="yes" swliveconnect="true" quality="autohigh" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent" menu="false" height="343" width="610"> </object></span><div style="position: absolute; left: 0px; top: 0px; width: 610px; height: 343px; z-index: 999189188; display: none;" id="asmspan_5192281_asmx"><a href="#" onclick="window.asmvi1_vast.showAd(true,true); return false"><img alt="" src="" border="0" height="343" width="610"></a></div><div style="position: absolute; left: 0px; top: 0px; z-index: 999189188; display: none; padding: 5px 10px; border-bottom: 1px solid white; border-right: 1px solid white; background-color: rgb(202, 221, 236);" id="asmspan_5192281_skipper"><a style="font-size:11pt; color:black; font-family:Arial; line-height:1em; text-decoration:none;" href="#" onclick="window.asmvi1_vast.skipAd(); return false">Skip »</a></div></div>

<script type="text/javascript" language="JavaScript">

<!--

var asmvi_id = "asmvi1";

var vastparam = new Object();

vastparam.width = 610;

vastparam.height = 343;

vastparam.left = 0;

vastparam.top = 0;

vastparam.events = new Object();

vastparam.events.AdLoaded = "";

vastparam.events.AdStarted = "";

vastparam.events.AdStopped = "";

vastparam.events.AdExpandedChange = "";

vastparam.events.AdRemainingTimeChange = "";

vastparam.events.AdVolumeChange = "";

vastparam.events.AdImpression = "";

vastparam.events.AdVideoStart = "";

vastparam.events.AdVideoFirstQuartile = "";

vastparam.events.AdVideoMidpoint = "";

vastparam.events.AdVideoThirdQuartile = "";

vastparam.events.AdVideoComplete = "ausblenden_ext";

vastparam.events.AdClickThru = "";

vastparam.events.AdPaused = "";

vastparam.events.AdPlaying = "";

-->

</script>

<script src="http://xxlmarketingsolution.adspirit.de/adasync.js" async="" type="text/javascript" language="JavaScript"></script>

<script type="text/javascript" language="JavaScript">
/* Ausblenden des Werbeframes */
function ausblenden_ext()
    {
    document.domain = 'spielenxxl.de'; 
    window.parent.document.getElementById("werbevideo").style.display = 'none';
    }
</script>

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-41585143-17', 'auto');
  ga('send', 'pageview');

</script>

我尝试了什么:

<script>
var myini = setInterval(function(){
var embeds = document.getElementsByTagName('embed');
if(embeds){
for (var i = 0; i < embeds.length; i++) {
        embeds[i].setAttribute("flashvars", embeds[i].getAttribute("flashvars").replace("mute=off", "mute=on").replace("volume=25", "volume=0"));
        embeds[i].setAttribute("src", embeds[i].getAttribute("src"));
}
clearInterval(myini);
}
//.replace("mute=off", "mute=on").replace("volume=25", "volume=0");
}, 200);
</script>

1 个答案:

答案 0 :(得分:0)

你做不到。玩家在另一个网站上,你无法控制它。相同的原始策略阻止通过JavaScript访问它。

如果您认为广告不适合您的网站,那么您可以与广告客户(或您作为中间人使用的广告平台)进行协商,或者只是拒绝将其包含在内。

您无法自行编辑广告。