youtube promoshon
<!DOCTYPE html>
<html>
<title>Monetization Help</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<div class=" container-fluid w3-content" style="margin-top:60px;" id="content-container">
<div class="row" id="playerContainer">
</div>
</div>
<script>
var totalVideosMin=0;
var jequeryAlertFunction;
$(document).ready(function(){
});
var vids = ["aZiBmzHQTIk","HPkydJOXXNs","LpKkRyA6ffQ","Y0INPqSEv2M"];
var vids2 = {"aZiBmzHQTIk":0,"HPkydJOXXNs":0,"LpKkRyA6ffQ":0,"Y0INPqSEv2M":0};
var vids3 = {"aZiBmzHQTIk":0,"HPkydJOXXNs":0,"LpKkRyA6ffQ":0,"Y0INPqSEv2M":0};
//var num_of_videos=vids.length;
var num_of_videos=0;
channel_id='UC1cEPAYZbD7z9MSvnvR7Mtw';
promotedChannelId='';
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var curplayer=[];
function onYouTubeIframeAPIReady() {
for(var i = 0; i < vids.length;i++) {
var node = document.createElement("DIV");
var node2 = document.createElement("DIV");
var node3 = document.createElement("DIV");
k=document.getElementById("playerContainer").appendChild(node);
k.className="col-md-3 playerTimerContainer";
g=node.appendChild(node2);
g.id='player'+i.toString();
g.className='playerStyle';
l=node.appendChild(node3);
l.id='video'+vids[i];
l.className='timerStyle';
var textnode = document.createTextNode("00:00");
node3.appendChild(textnode);
curplayer[i] = createPlayer(i);
}
}
function createPlayer(j) {
var player='player'+j.toString();
var videoid=vids[j];
return new YT.Player(player, {
height: '200',
width: '93%',
videoId: vids[j],
events: {
'onReady': function (e) {
onPlayerReady();
e.target.mute();
},
'onStateChange': function(event){
onPlayerStateChange(event, videoid);
}
}
});
}
var done = false;
var array=[];
var refreshIntervalId=[];
var refreshIntervalId2=[];
var seconds=[];
var minutesCovered=[];
function display(id,totalTimeInSeconds)
{
if(typeof seconds[id] === "undefined")
{
seconds[id]=1;
minutesCovered[id]=0;
array[id]=0;
}
else
{
if(seconds[id]%60==0 && seconds[id]!=0)
{
minutesCovered[id]++;
totalVideosMin++;
totalTimeInSeconds=Math.floor(totalTimeInSeconds);
var percentage=(minutesCovered[id]/(totalTimeInSeconds/60))*100;
percentage=Math.ceil(percentage);
if(percentage>90)
{
if(vids2[id]==0)
{
vids2[id]=1;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xmlhttp.open("GET", "videoDataInsert2.php?video_id="+id, true);
xmlhttp.send();
}
}
document.getElementById("totalCounter").innerHTML=totalVideosMin;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xmlhttp.open("GET", "videoDataInsert.php?sec=" + seconds[id]+"&video_id="+id+"&channel_id="+channel_id, true);
xmlhttp.send();
seconds[id]=0;
}
if(minutesCovered[id]>=2)
{
if(vids3[id]==0)
{
vids3[id]=1;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xmlhttp.open("GET", "subscribeDataInsert.php?video_id="+id+"&subscribee="+channel_id, true);
xmlhttp.send();
}
}
seconds[id]=seconds[id]+1;
if(seconds[id]>=10)
document.getElementById('video'+id).innerHTML="0"+minutesCovered[id].toString()+":"+seconds[id].toString();
else
document.getElementById('video'+id).innerHTML="0"+minutesCovered[id].toString()+":0"+seconds[id].toString();
array[id]=seconds[id];
}
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
function onPlayerStateChange(event,id) {
if (event.data == YT.PlayerState.PLAYING) {
var presentTime=event.target.getCurrentTime();
var totalTimeinSec=event.target.getDuration();
array[id]=totalTimeinSec;
refreshIntervalId[id]=setInterval( function() { display(id,totalTimeinSec); }, 1000);
event.target.setPlaybackQuality("small");
num_of_videos++;
document.getElementById('noOfVideosPlaying').innerHTML=num_of_videos;
}
else if(event.data == YT.PlayerState.BUFFERING)
{
clearInterval(refreshIntervalId[id]);
}
else if(event.data == YT.PlayerState.PAUSED)
{
clearInterval(refreshIntervalId[id]);
}
else if(event.data == YT.PlayerState.ENDED)
{
clearInterval(refreshIntervalId[id]);
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//event.target.playVideo();
}
};
xmlhttp.open("GET", "videoDataInsert.php?sec=" + seconds[id]+"&video_id="+id+"&channel_id="+channel_id, true);
xmlhttp.send();
seconds[id]=0;
num_of_videos=num_of_videos-1;
var status=yes();
if(!status)
{
setTimeout(function() { //calls click event after a certain time
// window.open('subscribeChannel.php?minutes='+totalVideosMin+'&channel_id='+promotedChannelId,'_self');
window.open('profile.php','_self');
}, 5000);
}
}
}
function yes()
{
var status= false;
for(var l=0;l<curplayer.length;l++)
{
if(curplayer[l].getPlayerState()==1 || curplayer[l].getPlayerState()==3)
{
status= true;
}
else
{
continue;
}
}
if(status)
return 1;
else
return 0;
}
function pause()
{
for(var l=0;l<curplayer.length;l++)
{
curplayer[l].pauseVideo();
}
}
function resume()
{
for(var l=0;l<curplayer.length;l++)
{
curplayer[l].playVideo();
}
}
</script>
</body>
</html>
Comments (0)
Facebook Comments (0)