home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 October / Chip_2002-10_cd1.bin / servis / wm9 / download / mpsetup.exe / wmploc.DLL / 256 / CORPORATE.JS < prev    next >
Encoding:
JavaScript  |  2002-08-19  |  7.3 KB  |  281 lines

  1. //<script>
  2. //SKIN MUST INCLUDE res://wmploc/RT_TEXT/#169 as a scriptfile
  3.  
  4. var g_kCaptionWindowHeight=100;
  5. var g_kDefaultViewHeight=274;
  6. var g_kDefaultViewWidth=300;
  7. var g_kDefaultScreenHeight=204;
  8. var g_kDefaultViewHeightCaptions=(g_kDefaultViewHeight+g_kCaptionWindowHeight);
  9.  
  10. var g_kMinimumResizeHeight = 140;
  11. var g_kMinimumResizeWidth = g_kDefaultViewWidth;
  12.  
  13. function InitCorporate()
  14. {
  15.     DoSnapToSize();
  16.     svLogo.alphaBlendTo(0,1900); 
  17.     InitSamiDisplay();
  18.     InitVisualizations(); // Init the Video and Visualization windows
  19.     InitCorporateControls();
  20. }
  21.  
  22. var g_lastVideoHeight=-1;
  23. var g_lastVideoWidth=-1;
  24. var g_lastUserAudioHeight=-1;
  25. var g_lastUserAudioWidth=-1;
  26. var g_captionsWereShowingOnLastAudio=null;
  27.  
  28.  
  29. function DoSnapToSize()
  30. {
  31.     if (player.openState==osMediaOpen)
  32.     {
  33.         var h = player.currentMedia.imageSourceHeight; 
  34.         var w = player.currentMedia.imageSourceWidth;
  35.         // do this only if it is different than the previous file's height/width
  36.         if ( (h!=g_lastVideoHeight) || (w!=g_lastVideoWidth) )
  37.         {
  38.             if ( (h!=0) && (w!=0) )
  39.             {
  40.                 if (g_lastVideoHeight==0)
  41.                 {
  42.                     g_lastUserAudioHeight=view.height;
  43.                     g_lastUserAudioWidth=view.width;
  44.                     g_captionsWereShowingOnLastAudio = mediacenter.showCaptions;
  45.                 }             
  46.                 SnapToVideoSize(h,w);
  47.             }
  48.             else
  49.             {
  50.                 if ( (g_lastVideoHeight>0) && (g_lastUserAudioHeight>0))
  51.                 {
  52.                     if (g_captionsWereShowingOnLastAudio != mediacenter.showCaptions)
  53.                     {
  54.                         view.height = g_captionsWereShowingOnLastAudio ? g_lastUserAudioHeight - g_kCaptionWindowHeight : g_lastUserAudioHeight + g_kCaptionWindowHeight;
  55.                     }
  56.                     else
  57.                     {
  58.                         view.height = g_lastUserAudioHeight;
  59.                     }
  60.                     view.width=g_lastUserAudioWidth;
  61.                 }
  62.             }
  63.             g_lastVideoHeight = h;
  64.             g_lastVideoWidth = w;
  65.         }
  66.     }
  67. }
  68.  
  69. function SnapToVideoSize(isHeight, isWidth)
  70. {
  71.     if (null!=isHeight)
  72.     {    
  73.         isHeight = isHeight*(mediacenter.videoZoom/100);
  74.         var nonVideoHeight = view.height - svScreen.height;
  75.         var newWindowHeight = Math.max(isHeight+nonVideoHeight,g_kMinimumResizeHeight);
  76.         view.height = newWindowHeight;
  77.     }
  78.     
  79.     if (null!=isWidth)
  80.     {
  81.         isWidth = isWidth*(mediacenter.videoZoom/100);
  82.         var nonVideoWidth = view.width - svScreen.width;
  83.         var newWindowWidth = Math.max(isWidth + nonVideoWidth,g_kMinimumResizeWidth);
  84.         view.width = newWindowWidth;
  85.     }
  86. }
  87.  
  88. function InitVisualizations()
  89. {
  90.     if (player.openState==osMediaOpen)
  91.     {
  92.         if (player.currentMedia.ImageSourceWidth > 0)
  93.         {
  94.             myeffect.visible=false;
  95.             video1.visible=true;
  96.         } 
  97.         else 
  98.         { 
  99.             video1.visible=false;
  100.             myeffect.visible=mediacenter.showEffects;
  101.         }
  102.     }
  103. }
  104.  
  105. function OnPlayStateChangeViz()
  106. {
  107.     InitVisualizations();
  108. }
  109.  
  110. function OnOpenStateChangeViz()
  111. {
  112.     InitVisualizations();
  113. }
  114.  
  115. function AutoSize()
  116. {
  117.     if (player.openState==osMediaOpen)
  118.     {
  119.         DoSnapToSize();
  120.     }
  121.     else
  122.     {
  123.         if (mediacenter.showCaptions)
  124.         {
  125.             view.height=g_kDefaultViewHeightCaptions;
  126.         }
  127.         else
  128.         {
  129.             view.height=g_kDefaultViewHeight;
  130.         }
  131.         view.width=g_kDefaultViewWidth;
  132.     }
  133. }
  134.  
  135.  
  136. function CheckForAdBanner(media)
  137. {   
  138.     var oldHeight = svBanner.height;
  139.     if (media.getItemInfo('BannerURL') != '')
  140.     {
  141.         AdBanner.image="WMPImage_AdBanner";
  142.         svBanner.height=AdBanner.height;
  143.         AdBanner.tabStop=true;
  144.     }
  145.      
  146.     else
  147.     {
  148.         svBanner.height=0;
  149.         AdBanner.tabStop=false;
  150.     }
  151.     if (svBanner.height!=oldHeight)
  152.     {    
  153.         svVideo.height  = view.height - svTransport.height - svBanner.height; 
  154.         svVisual.height = view.height - svTransport.height - svBanner.height;
  155.         svBanner.top    = svVideo.top + svVideo.height;
  156.     }
  157. }
  158.  
  159. function OnBannerClick()
  160. {
  161.     if (player.openState==osMediaOpen)
  162.     {
  163.         var strTargetURL = player.currentmedia.getItemInfo("BannerInfoURL");
  164.         if ( strTargetURL != "")
  165.         {
  166.             player.launchURL(strTargetURL);   
  167.         }
  168.     }
  169. }
  170.  
  171. function OnBannerMouseOver()
  172. {
  173.     if (player.openState==osMediaOpen)
  174.     {
  175.         if ( player.currentmedia.getItemInfo("BannerInfoURL") != "")
  176.         {
  177.             AdBanner.cursor = "hand";
  178.         }
  179.         else
  180.         {
  181.             AdBanner.cursor = "system";
  182.         }
  183.     }
  184. }
  185.  
  186. function CaptionsView_OnOpenStateChangeEvent(NewState)
  187. {
  188.     switch (NewState)
  189.     {
  190.         case osMediaChanging:
  191.             ClearSamiDisplay();
  192.             break;
  193.     }
  194. }
  195.  
  196. function InitSamiDisplay()
  197. {
  198.     Browser1.loadSpecialPage("SAMI");
  199. }
  200.  
  201. function ClearSamiDisplay()
  202. {
  203.     handleScriptCommand("Text", "");
  204. }
  205.  
  206. function handleScriptCommand(scType, Param)
  207. {
  208.     var Document = 0;
  209.     var ElemCollection = 0;
  210.     var Element = 0;
  211.     scType = scType.toUpperCase();
  212.  
  213.     if(scType == "TEXT" ||  scType == "<SYNC" || scType == "CAPTION")
  214.     {
  215.         Browser1.showSAMIText(Param);
  216.     }
  217. }
  218.  
  219. function SetCaptions(visible)
  220. {
  221.     var oldWidth = view.width;
  222.     if (svTransport.top)
  223.     {
  224.         svScreen.verticalAlignment="top";
  225.         if (visible) 
  226.         {
  227.             var intendedHeight = svCaptions.top + g_kCaptionWindowHeight + svTransport.height;
  228.             view.height = intendedHeight;
  229.             if (view.height != intendedHeight)
  230.             {
  231.                theme.currentViewID=(view.id);              
  232.             }
  233.  
  234.             Browser1.height=g_kCaptionWindowHeight;
  235.         }
  236.         else
  237.         {
  238.             view.height = svCaptions.top + svTransport.height;            
  239.         }
  240.         svScreen.verticalAlignment="stretch";
  241.     }
  242.     if (view.width!=oldWidth)
  243.     {
  244.         theme.currentViewID=(view.id);              
  245.     }
  246. }
  247.  
  248. function InitCorporateControls()
  249. {
  250.     if (view.id=="corporateWB")
  251.     {
  252.         g_strPlayImage="res://wmploc/#1849";
  253.         g_strPlayHover="res://wmploc/#1849";
  254.         g_strPlayDown="res://wmploc/#1849";
  255.         g_strPauseUp="res://wmploc/#1851";
  256.         g_strPauseHover="res://wmploc/#1851";
  257.         g_strPauseDown="res://wmploc/#1851";
  258.     }
  259.     else if (view.id=="corporateBW")
  260.     {
  261.         g_strPlayImage="res://wmploc/#1864";
  262.         g_strPlayHover="res://wmploc/#1864";
  263.         g_strPlayDown="res://wmploc/#1864";
  264.         g_strPauseUp="res://wmploc/#1865";
  265.         g_strPauseHover="res://wmploc/#1865";
  266.         g_strPauseDown="res://wmploc/#1865";
  267.     }
  268.     else
  269.     {
  270.         g_strPlayImage="res://wmploc/#1815";
  271.         g_strPlayHover="res://wmploc/#1816";
  272.         g_strPlayDown="res://wmploc/#1817";
  273.         g_strPauseUp="res://wmploc/#1818";
  274.         g_strPauseHover="res://wmploc/#1819";
  275.         g_strPauseDown="res://wmploc/#1820";    
  276.     }
  277.  
  278.     OnOpenStateChangeTransport(player.openState);
  279.     OnPlayStateChangeTransport(player.playState);
  280.     OnStatusChangeTransport(player.status);
  281. }