I have a variable "mail" inside "onPlayerReady" in which i have email adress, i want to call this variable inside "onPlayerStateChange" so that i can pass the value to 'input.php' page to save it into database.
$(function(){
var youtubePlayer;
var myWindow = window;
var vid_id='ha48nSKLLh8';
onYouTubeIframeAPIReady = function(){
youtubePlayer = new YT.Player('youtube', {
height: '390',
width: '640',
videoId: vid_id,
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
onPlayerReady = function(event) {
event.target.pauseVideo();
var mail=prompt('email:'); //this is the variable mail i am talking about i want the value if this variable inside onPlayerStateChange
};
onPlayerStateChange = function(event) {
if (event.data == 1) {
var tm = youtubePlayer.getCurrentTime();
var st = youtubePlayer.getPlayerState();
//$("#status1").text(tm);
$("#status1").text(st);
$.ajax({
type: 'POST',
url: 'input.php',
data:{ tm: tm, vid_id: vid_id,mail:mail},
success:function(html){
alert(done);
}
});
//$("#status1").text(tm);
$("#status").text("Playing!");
myWindow.focus();
myWindow.onblur = function() {
$("#status").text("You went away!");
youtubePlayer.stopVideo();
};
}
};
youtubeplayer.bind('play',function(){
youtubeplayer.time(60);
return this.unbind;
});
})
please help me with this or suggest me if there is any other way to save the email entered at "onPlayerReady". Thanks in advance!