home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / temacd / imtoodownyoutube / download-youtube-video.exe / script / preview.js < prev    next >
Text File  |  2007-09-11  |  12KB  |  479 lines

  1.  
  2.     LoadLib("MyFileDialog.dll");
  3.     LoadLib("Helper.dll");
  4.     var help=new JSHelper;
  5.     help.Helper_Init();
  6.  
  7.      var timerpos = 0; var fileinfopath="";
  8.     
  9.      var timer1=0;var m_bplayer=0;
  10.      preview.curplay.SetText("00:00:00");
  11.      preview.totalplay.SetText("00:00:00");
  12.  
  13.      var ini = new JSIniFile("player.ini");
  14.     
  15.      ExportObj(ini,"g_Config");                                                                                                                    
  16.     
  17.       
  18.   player_init();
  19.   preview.v1.SetPos(100);
  20.  
  21.  function player_init()
  22.  { 
  23.            ini.ReadFile();
  24.           var langstr=g_Config.GetValue("general","language","English");
  25.           changlanguage(langstr);
  26.           var skinstr=g_Config.GetValue("general","skin","newskin");
  27.           changskin(skinstr);
  28.     
  29.  }
  30.  function SliderChange(args)
  31.          var pos = args[2];
  32.          var isDrag = args[3];
  33.          timerpos = pos;
  34.          preview.player1.Player_SeekTo(timerpos);
  35.     
  36. }
  37.  
  38. function changevolume(args)
  39. {    
  40.       
  41.       args[2]+=20;
  42.       if(args>100)
  43.          args[2]=100;
  44.       preview.player1.Player_SetVolume(args[2]);
  45.     
  46. }
  47.      
  48. var strtime="";
  49. function getstrtime(time)
  50. {
  51.       var h=parseInt(time/3600);
  52.       var m=parseInt((time-h*3600)/60);
  53.       var s=time%60;
  54.       if(h<10)h="0"+h;
  55.       if(m<10)m="0"+m;
  56.       if(s<10)s="0"+s;
  57.       strtime=h+":"+m+":"+s;
  58.       return strtime;
  59. }
  60.     
  61.     var bjplay=0,bjstop=0;
  62. function play(filename)
  63. {
  64.   
  65.       var totaltime=preview.player1.Player_GetTotalTime();
  66.       preview.totalplay.SetText(getstrtime(totaltime));
  67.       var curtime=preview.player1.Player_GetCurrentTime();
  68.       preview.curplay.SetText(getstrtime(curtime));
  69.       preview.play111.SetEnable(true);
  70.       
  71.       playerpath=filename;
  72.       preview.menupopup.play.SetEnable(true);
  73.       preview.volume.SetEnable(true);
  74.       
  75.       m_bplayer=1;
  76.       playplay();
  77.  
  78.  
  79. }
  80. function playplay()
  81.     
  82.     
  83.  if(bjplay==0)
  84.  {
  85.        if(bjstop==1)
  86.         preview.player1.Player_SetFile(playerpath);
  87.       if(bjvolume==1)
  88.                     preview.player1.Player_SetVolume(0);
  89.       else 
  90.       preview.player1.Player_SetVolume(preview.v1.GetPos());
  91.        
  92.        preview.play111.SetImage("player-pause.png");
  93.        preview.play111.SetTipText(LanguageStr("_player_menu_pause"));
  94.        preview.playstop.SetEnable(true);
  95.        preview.menuofplay.SetEnable(false);
  96.        preview.menuofstop.SetEnable(true);
  97.        preview.menuofpause.SetEnable(true);
  98.        preview.menupopup.play.SetEnable(false);
  99.        preview.menupopup.pause.SetEnable(true);
  100.        preview.menupopup.stop.SetEnable(true);
  101.        preview.volume.SetEnable(true);
  102.      
  103.        bjstop=0;
  104.     
  105.        preview.player1.Player_Play();
  106.        bjplay=1;
  107. }
  108.  else if(bjplay==1)
  109.      { preview.play111.SetImage("player-play.png");
  110.        bjplay=0;
  111.        playpause();  
  112.        preview.play111.SetTipText(LanguageStr("_player_btn_tooltip_play"));
  113.        
  114.        preview.menuofpause.SetEnable(false);
  115.        preview.menuofplay.SetEnable(true);
  116.        preview.menuofstop.SetEnable(true);
  117.        preview.menupopup.play.SetEnable(true);
  118.        preview.menupopup.pause.SetEnable(false);
  119.        preview.menupopup.stop.SetEnable(true);
  120.        
  121.        return 1;
  122. }
  123.  preview.menuoffullscreen.SetEnable(true);
  124.  
  125.  
  126.   if(timer1==0)
  127.   {
  128.   preview.SetTimer(2,1000,"timerfunc");
  129.   timer1=1;
  130.  }
  131.  
  132. }
  133.     
  134. function timerfunc(args)
  135. {
  136.     
  137.     if(timer1==0) preview.KillTimer(1);
  138.     timerpos=getprogress();
  139.     preview.slider1.SetPos(timerpos);
  140.     if(timerpos >=100)
  141.     {
  142.         timerpos = 0;
  143.         preview.slider1.SetPos(0);
  144.         playstop();
  145.         preview.KillTimer(1);
  146.     }
  147.   var curtime=preview.player1.Player_GetCurrentTime();
  148.   
  149.   preview.curplay.SetText(getstrtime(curtime));
  150.     
  151. }
  152. function playstop()
  153. {       
  154.         preview.play111.SetImage("player-play.png");
  155.         preview.play111.SetEnable(true);
  156.         preview.playstop.SetEnable(false);
  157.         preview.play111.SetTipText(LanguageStr("_player_btn_tooltip_play"));
  158.     
  159.     
  160.         bjplay=0;
  161.         preview.player1.Player_Stop();
  162.         preview.menuofplay.SetEnable(true);
  163.         preview.menuofpause.SetEnable(false);
  164.         preview.menuofstop.SetEnable(false);
  165.         preview.menupopup.play.SetEnable(true);
  166.         preview.menupopup.pause.SetEnable(false);
  167.         preview.menupopup.stop.SetEnable(false);
  168.          preview.menuoffullscreen.SetEnable(false);
  169.         preview.slider1.SetPos(0);
  170.         preview.volume.SetEnable(false);
  171.         bjstop=1;
  172.         timer1=0;
  173.         if(bjfullscreen==1)
  174.         {
  175.           preview.menupopup.size.SetText(LanguageStr("_player_menu_fullscr"));
  176.           bjfullscreen=0;
  177.         }
  178. }
  179. function playpause()
  180. {     //  preview.play111.SetImage("player-play.png");
  181.     preview.player1.Player_Pause();
  182.     timer1=0;
  183. }
  184.  
  185. function getprogress()
  186. {
  187.        return preview.player1.Player_GetProgress();
  188. }
  189. function preview_close()
  190. {
  191.      if(timer1==1)
  192.      {
  193.            timer=0;
  194.            preview.KillTimer(2);
  195.      }
  196.      if(m_bplayer==1)
  197.      {
  198.            preview.player1.Player_Stop();
  199.            m_bplayer=0;
  200.      }
  201.      
  202.      preview.Close();
  203. }
  204.  
  205. var mydlg=new JSMyFileDialog();
  206. var playerpath="";
  207.     
  208. function showdir1()
  209. {
  210.      var path=mydlg.showdir();
  211.      if(path=="")
  212.      return;
  213.      playerpath=path;
  214.     
  215.      if(playerpath.substr(playerpath.length-4,4)!=".flv")
  216.         return;
  217.      
  218.      if(playerpath!="")
  219.      {
  220.           bjplay=0;
  221.           preview.menuoffileinfo.SetEnable(true);
  222.           preview.player1.Player_SetFile(playerpath);
  223.           preview.menuoffullscreen.SetEnable(true);
  224.           play(playerpath);
  225.         
  226.     }
  227.      else
  228.      {
  229.        return 1;
  230.      }
  231. }
  232.  
  233. function getfileinfos(playerpath)
  234. {
  235.      GetFileInfo(playerpath);
  236.      playerfileinfos.ShowModal();     
  237.      
  238.  
  239. }
  240. function change(args)
  241. {
  242.     var vol=args+20;
  243.     if(vol>100)
  244.        vol=100;
  245.      preview.player1.Player_SetVolume(vol);
  246. }
  247.     
  248. function ondropme(args)
  249. {
  250.     
  251.       if(m_bplayer==1)
  252.      {preview.player1.Player_Stop(); }
  253.     
  254.      playerpath=args[2]; 
  255.      preview.slider1.SetPos(0);
  256.      bjplay=0;
  257.      preview.player1.Player_SetFile(playerpath);
  258.      play(playerpath);
  259.      preview.menuoffullscreen.SetEnable(true);
  260.      preview.menuoffileinfo.SetEnable(true);
  261.      preview.menuofplay.SetEnable(false);
  262.      preview.menuofpause.SetEnable(true);
  263.      preview.menuofstop.SetEnable(true);
  264.      preview.menupopup.play.SetEnable(false);
  265.      preview.menupopup.pause.SetEnable(true);
  266.      preview.menupopup.stop.SetEnable(true);
  267.  
  268. }
  269. function showpreview_about()
  270. {
  271.     /*  if (Product.IsValidateReg())
  272.     {
  273.         var reginfo = Product.GetRegInfo();
  274.         preview_about.username.SetText(reginfo[0]);
  275.         preview_about.RegTip.SetText(LanguageStr("_about__status_reg"));
  276.     }else
  277.     {
  278.         preview_about.RegTip.SetText(LanguageStr("_about__status_unreg"));
  279.         preview_about.username.SetText("");
  280.     }*/
  281.     preview_about.aboutplayer.SetText(LanguageStr("_flvmain_menu_about")+" "+"ImTOO Flv Player");
  282.     preview_about.ShowModal();
  283. }
  284.  
  285.     
  286. var bjvolume=0;
  287. function openvolume()
  288. {     
  289.         if(bjvolume==0)
  290.        {
  291.             preview.player1.Player_SetMutex(1);
  292.             preview.volume.SetImage("mute.png");
  293.             bjvolume=1;
  294.         }
  295.         else
  296.         {
  297.              preview.player1.Player_SetMutex(0);
  298.              preview.volume.SetImage("volume.png");
  299.              bjvolume=0;
  300.         }
  301. }
  302.     
  303.  function rclick(args)
  304. {  
  305.      preview.menupopup.Popup();
  306. }
  307.  
  308.  
  309.  var bjfullscreen=0;
  310.  
  311.  function onsize()
  312.  {
  313.        if(bjfullscreen==0)
  314.        {
  315.           preview.player1.Player_ToggleToFullScreen();
  316.           preview.menuoffullscreen.SetEnable(false);
  317.           preview.menupopup.size.SetText(LanguageStr("_player_menu_normalsize"));
  318.           bjfullscreen=1;
  319.      
  320.        }
  321.        else if(bjfullscreen==1)
  322.        {
  323.              preview.player1.Player_ToggleToFullScreen();
  324.           preview.menuoffullscreen.SetEnable(true);
  325.           preview.menupopup.size.SetText(LanguageStr("_player_menu_fullscr"));
  326.           bjfullscreen=0;
  327.        }
  328.    
  329.  }
  330.  
  331. function doubleclick()
  332. {
  333.     onsize();
  334. }
  335. function previw_help()
  336. {
  337.   var urlstr = "Youtube Download.chm";
  338.     if(urlstr.length <= 0)
  339.     {
  340.         return 1;
  341.     }
  342.     
  343.     GotoUrl(urlstr);
  344. }
  345.  
  346. function changlanguage(langstr)
  347. {
  348.       RefreshLanguage(langstr);
  349.     
  350.         if(langstr=="Chinese(Simplified)")
  351.     {
  352.         preview.tools.language.english.SetCheck(false);
  353.         preview.tools.language.chinese.SetCheck(true);
  354.         preview.tools.language.german.SetCheck(false);
  355.         preview.tools.language.japanese.SetCheck(false);
  356.     
  357.     }else if(langstr=="English")
  358.     {   
  359.         preview.tools.language.english.SetCheck(true);
  360.         preview.tools.language.chinese.SetCheck(false);
  361.         preview.tools.language.german.SetCheck(false);
  362.         preview.tools.language.japanese.SetCheck(false);
  363.     }else if(langstr=="Deutsch")
  364.     {
  365.         preview.tools.language.english.SetCheck(false);
  366.         preview.tools.language.chinese.SetCheck(false);
  367.         preview.tools.language.german.SetCheck(true);
  368.         preview.tools.language.japanese.SetCheck(false);
  369.     }else
  370.     {
  371.         preview.tools.language.english.SetCheck(false);
  372.         preview.tools.language.chinese.SetCheck(false);
  373.         preview.tools.language.german.SetCheck(false);
  374.         preview.tools.language.japanese.SetCheck(true);
  375.     }
  376.     g_Config.SetValue("general","language",langstr);
  377. }
  378. function changskin(skinstr)
  379. {
  380.     var pos=preview.v1.GetPos();
  381.     LoadSkin(skinstr);
  382.  
  383.     if(skinstr=="newskin")
  384.     {preview.v1.SetPos(pos);
  385.      preview.tools.skin.newskin.SetCheck(true);
  386.      preview.tools.skin.greenskin.SetCheck(false);
  387.      
  388.     }
  389.     else if(skinstr=="upod_green")
  390.     {preview.v1.SetPos(pos);
  391.      preview.tools.skin.newskin.SetCheck(false);
  392.      preview.tools.skin.greenskin.SetCheck(true);
  393.      
  394.     }
  395.     g_Config.SetValue("general","skin",skinstr);
  396. }
  397. function changeenglish()
  398. {
  399.     changlanguage("English");
  400.     g_Config.SetValue("general","language","English");
  401.     //if(help.Helper_IsConverterVisible())
  402.      //  help.Helper_StartUpModule("ImTOO Download YouTube Video.exe","-language English");
  403. }
  404. function changechinese()
  405. {
  406.     changlanguage("Chinese(Simplified)");
  407.     g_Config.SetValue("general","language","Chinese(Simplified)");
  408.     //if(help.Helper_IsConverterVisible())
  409.       // help.Helper_StartUpModule("ImTOO Download YouTube Video.exe","-language Chinese(Simplified)");
  410. }
  411. function changegerman()
  412. {
  413.     changlanguage("Deutsch");
  414.     g_Config.SetValue("general","language","Deutsch");
  415.     //if(help.Helper_IsConverterVisible())
  416.       // help.Helper_StartUpModule("ImTOO Download YouTube Video.exe","-language Deutsch");
  417. }
  418. function changejapan()
  419. {
  420.     changlanguage("Japanese");
  421.     g_Config.SetValue("general","language","Japanese");
  422.     //if(help.Helper_IsConverterVisible())
  423.       // help.Helper_StartUpModule("ImTOO Download YouTube Video.exe","-language Japanese");
  424. }
  425. function changenewskin()
  426. {
  427.     changskin("newskin");
  428.     g_Config.SetValue("general","skin","newskin");
  429.     //if(help.Helper_IsConverterVisible())
  430.       // help.Helper_StartUpModule("ImTOO Download YouTube Video.exe","-skin newskin");
  431.     
  432. }
  433. function changegreen()
  434. {
  435.     changskin("upod_green");
  436.     g_Config.SetValue("general","skin","upod_green");
  437.     //if(help.Helper_IsConverterVisible())
  438.     //{
  439.      //  help.Helper_StartUpModule("ImTOO Download YouTube Video.exe","-skin upod_green");
  440.     //}
  441. }
  442.  
  443.  LoadLib("MemoryShare.dll");
  444.  var MemoryShare = new JSMemoryShare();    
  445.  MemoryShare.MemoryShare_Init();
  446.  function OnSyncSkin(args)
  447.  { 
  448.       changskin(args[3]);
  449.      
  450.  }
  451.  
  452.  function OnSyncLanguage(args)
  453.  { 
  454.    changlanguage(args[3]);
  455.   
  456.  
  457.  }
  458.  
  459.  function OnPlayFile(args)
  460.  {
  461.      if(args[0]!=4)
  462.         return;
  463.         
  464.     bjplay=0;
  465.     preview.player1.Player_SetFile(args[3]);
  466.     play(args[3]);
  467.     // play(playerpath);
  468.     preview.menuoffullscreen.SetEnable(true);
  469.     preview.menuoffileinfo.SetEnable(true);
  470.     preview.menuofplay.SetEnable(false);
  471.     preview.menuofpause.SetEnable(true);
  472.     preview.menuofstop.SetEnable(true);
  473.     preview.menupopup.play.SetEnable(false);
  474.     preview.menupopup.pause.SetEnable(true);
  475.     preview.menupopup.stop.SetEnable(true);
  476. }
  477.