home *** CD-ROM | disk | FTP | other *** search
/ Orthodox Religion Class (2nd Semester) / ReligieCls1Sem2.iso / js / VideoPlayer.js < prev   
Encoding:
JavaScript  |  2015-03-04  |  2.7 KB  |  89 lines

  1. var mainGame;
  2. var dates;
  3. var noLevelImages;
  4. var manifest = [];
  5. var audioPath = "";
  6. var gameName;
  7. var column;
  8. var scaleImages;
  9. var srcVideo;
  10.  
  11. function VideoPlayer(json) {
  12.     $("#bodyGame").empty();
  13.     dates = (json.dates === undefined) ? new GameDates() : json.dates;
  14.     gameName = (json.gameDates === undefined) ? "video" : json.gameDates;
  15.     sarcina = (json.sarcina === undefined)?"":json.sarcina;
  16.     srcVideo = (json.src === undefined) ? "" : json.src;
  17.     noLevelImages = (json.noLevelImages === undefined) ? 5 : json.noLevelImages;
  18.     //player.pause();
  19.     mainGame = new MainGame(json.title);
  20.     $("#acasa,#ajutor, #repeta, #verifica").remove();
  21.     $("#gameDialog").dialog("open");
  22.     if(sarcina.length != 0)
  23.         playSound(sarcina);
  24.     this.putVideo(json);
  25.     
  26.     
  27. };
  28.  
  29.  
  30.  
  31.  
  32. VideoPlayer.prototype.putVideo = function(json) {
  33.     var width = 0;
  34.     var height = 0;
  35.     if(json.properties != null){
  36.         width = json.properties.width;
  37.         height = json.properties.height;
  38.     }
  39. //    $("#gameDiv").css("background","transparent");
  40.     
  41.     $("#gameDiv").append("<div id='gameStage' style='position:absolute;left:"+((1024-width)/2)+"px;width:"+width+"px;'></div>");
  42.     
  43.      $("#gameStage").append(
  44.              "<br><br><br><video id='videoPlayer' width='720' height='540' style='z-index:1600;' " +//border-radius:48px;
  45.                          "controls src='"+srcVideo+"'></video>");
  46.     
  47. //    $("#videoPlayer").attr("style","width:"+width+"px;left:0px");
  48.         $("#videoPlayer").attr("style","padding-top:0px");
  49.         
  50.     
  51.     $("#stopVideo").css("display",""); 
  52.     $("#closeBtn,#stopVideo").css("position","absolute");
  53.     $("#closeBtn,#stopVideo").css("top",(scale*20)+"px");
  54.     $("#closeBtn").css("right",(scale*5)+"px");
  55.     $("#stopVideo").css("right", (75*scale)+"px");
  56.     
  57.     setStyleBtn($("#closeBtn"),80,80);
  58.     setStyleBtn($("#stopVideo"),117,100);
  59.     
  60.     function setStyleBtn(id,width,height) {
  61.         var resize = 1;
  62.         if(scale*width>35)
  63.             resize=35/(scale*width);
  64.         id.css("width", scale*width*resize+"px");
  65.         id.css("height", scale*height*resize+"px");
  66.         id.css("background-size", scale*(width)*resize + "px " + scale*(height)*resize+"px");
  67.         //id.css("padding-left","5px");
  68.     };
  69.  
  70.     //$("#closeBtn,#stopVideo").appendTo($("#gameStage"));
  71.     
  72.     
  73.     $("#stopVideo").css("display",""); 
  74.     $("#volum").remove();
  75.     
  76.     var video = document.getElementById("videoPlayer");        
  77.     $("#stopVideo").click(function() {
  78.        video.currentTime = 0;
  79.        video.pause();
  80.     });
  81.    
  82.     $("#gameStage").css("-webkit-transform", "scale(" + scale*3 + ")");
  83.     $("#gameStage").css("-webkit-transform-origin","0% 0%");
  84.     $("#gameStage").css("transform", "scale(" + scale*3 + ")");
  85.     $("#gameStage").css("transform-origin","0% 0%");
  86.     $("#gameStage").css("-ms-transform", "scale(" + scale*3 + ")");
  87.     $("#gameStage").css("-ms-transform-origin","0% 0%");
  88.      
  89. };