V
V
vsosedko882017-08-10 20:46:18
Software players
vsosedko88, 2017-08-10 20:46:18

How to make an ad player overlay on the main one, in js?

Hi all the people there was a question about the overlay of the player with advertising on the main player.
I found this code on the internet:

<script type="text/javascript" src="http://yandex.st/jquery/1.7.2/jquery.min.js"></script>

<div id="advm_preload" style="width:0px;height:0px;text-align:center;z-index:1000;overflow:hidden;">
<font color="#f0f0f0">Рекламма закроется автоматически через 20 сек</font>

<iframe width="560" height="315" src="https://www.youtube.com/embed/Zfy_8R9UBXs" frameborder="0" allowfullscreen></iframe>

<div style="background:#ffffff;color:#000000;">
    <span id="advm_close" style="cursor:pointer">Закрыть рекламу</span>
    <div style="border:red solid 1px;" class="advm_loader">Идет загрузка... осталось <span id="advm_timer"></span> сек.</div>
</div>
</div>

<script type="text/javascript">
$(function(){
    var advm_height = $('#advm_preload').parent().height();
    var advm_width = $('#advm_preload').parent().width();
    $('#advm_preload,#advm_close,.advm_loader,#advm_preload > div').css('display','block');
    $('#advm_preload').parent().find('object').append('<param name="wmode" value="opaque">');
    $('#advm_preload').parent().css('position', 'relative');
    $('#advm_preload').css({'position':'absolute', 'top':advm_height/2-230+'px', 'left':advm_width/2-350+'px', 'width':'700px', 'height':'450px'});
    $("#advm_timer").html(advm_timer);

    var advm_timer = 20;
    function advmPreload(){
        $("#advm_timer").html(advm_timer--);
        if(advm_timer>0){
            setTimeout(function(){ advmPreload(); },1000);
        }else{
            $("#advm_preload").hide();
        }
    }
    setTimeout(function(){ advmPreload(); },1000);
    $('#advm_close, #advm_preload').click(function(){
        $('#advm_preload').hide();
    });
});
</script>

So it seems like everything works, but here’s the question of how to make the close button appear after a certain time, and secondly, if the ad is closed without stopping the YouTube player, then the sound remains the same, is it possible to do something to close the ad when the button is pressed the video stopped and the ad player was hidden???? Help me please.
If anyone knows another solution for js or something else, please tell me.
P / s in js is completely 0 in other languages ​​\u200b\u200band also, I will be overly grateful if someone gives a ready-made solution.
Thank you all in advance for your replies.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question