home *** CD-ROM | disk | FTP | other *** search
/ Minami 48 / MINAMI48.ISO / Extra / MPSetup.exe / 1033 / RCDATA / CABINET / Compact.wmz / compact.js < prev    next >
Text File  |  2002-07-18  |  14KB  |  594 lines

  1. //<script>
  2.  
  3. var settingsIsOpen = false;
  4. var playlistIsOpen = false;
  5. var giSettingsPos = 0;
  6. var gsSettingsNames = new Array("SRSSettings", "AudioSettings", "VideoSettings");
  7.  
  8. var closedWidth = 422;
  9. var closedHeight = 378;
  10.  
  11. var rightMove = 179;
  12. var bottomMove = 102;
  13.  
  14. var movingDrawer = 0;
  15. var g_SetPlayPauseFocus=false;
  16.  
  17. function InitCompact()
  18. {
  19.     playlist.setColumnResizeMode( 0, "Stretches" );
  20.     playlist.setColumnResizeMode( 1, "AutoSizeData" );
  21.     InitCompactControls();
  22.     OnStateChange();
  23.     InitEQ();
  24.     InitSRS();
  25.     OnModeChange();
  26.  
  27.     // load saved settings
  28.     var s = "";    
  29.  
  30.     s = theme.loadPreference("SettingsTab");
  31.     for (var i = 0; i < gsSettingsNames.length; i++)
  32.     {
  33.         if (s == gsSettingsNames[i])
  34.         {
  35.             giSettingsPos = i;
  36.         }
  37.     }
  38.     ChangeSettingsTab(0); // Init settings tab
  39.     
  40.     s = theme.loadPreference("SettingsDrawer");
  41.     if (s == "True")
  42.         ToggleSettings();
  43.  
  44.     s = theme.loadPreference("PlaylistDrawer");
  45.     if (s == "True")
  46.         TogglePlaylist();
  47.  
  48.     SetAlignment( true );
  49.     DoSnapToSize();
  50. }
  51.  
  52. function InitCompactControls()
  53. {
  54.     g_bufferingProgress = player.network.bufferingProgress;
  55.     OnOpenStateChangeTransport(player.openState);
  56.     OnPlayStateChangeTransport(player.playState);
  57.     OnStatusChangeTransport(player.status);
  58. }
  59.  
  60. function CloseCompact()
  61. {
  62.     theme.savePreference("SettingsTab", gsSettingsNames[giSettingsPos]);
  63.     theme.savePreference("SettingsDrawer", settingsIsOpen);
  64.     theme.savePreference("PlaylistDrawer", playlistIsOpen);
  65. }
  66.  
  67. var g_lastVideoHeight=-1;
  68. var g_lastVideoWidth=-1;
  69. var g_lastUserAudioHeight=-1;
  70. var g_lastUserAudioWidth=-1;
  71. var g_fNeedSnap = false;
  72.  
  73. function DoSnapToSize()
  74. {
  75.     if (movingDrawer != 0)
  76.     {
  77.         g_fNeedSnap = true;
  78.     }
  79.     else if (player.openState==osMediaOpen)
  80.     {
  81.         g_fNeedSnap = false;
  82.  
  83.         var h = player.currentMedia.imageSourceHeight; 
  84.         var w = player.currentMedia.imageSourceWidth;
  85.         // do this only if it is different than the previous file's height/width
  86.         if ( (h!=g_lastVideoHeight) || (w!=g_lastVideoWidth) )
  87.         {
  88.             if ( (h!=0) && (w!=0) )
  89.             {
  90.                 if (g_lastVideoHeight==0)
  91.                 {
  92.                     g_lastUserAudioHeight=view.height;
  93.                     g_lastUserAudioWidth=view.width;
  94.                 }             
  95.                 SnapToVideoSize(h,w);
  96.             }
  97.             else
  98.             {
  99.                 if ( (g_lastVideoHeight>0) && (g_lastUserAudioHeight>0))
  100.                 {
  101.                     settingsDrawer.verticalAlignment    = "bottom";
  102.                     playlistDrawer.horizontalAlignment  = "right";
  103.  
  104.                     view.height = g_lastUserAudioHeight;
  105.                     view.width  = g_lastUserAudioWidth;
  106.  
  107.                     settingsDrawer.verticalAlignment    = "top";
  108.                     playlistDrawer.horizontalAlignment  = "left";
  109.                 }
  110.             }
  111.             g_lastVideoHeight = h;
  112.             g_lastVideoWidth = w;
  113.         }
  114.     }
  115. }
  116.  
  117. function SnapToVideoSize(isHeight,isWidth)
  118. {
  119.     settingsDrawer.verticalAlignment    = "bottom";
  120.     playlistDrawer.horizontalAlignment  = "right";
  121.  
  122.     if (null!=isHeight)
  123.     {    
  124.         isHeight = isHeight*(mediacenter.videoZoom/100);
  125.         var nonVideoHeight = view.height - video1.height;
  126.         var newWindowHeight = isHeight+nonVideoHeight;
  127.         view.height = newWindowHeight;
  128.     }
  129.     
  130.     if (null!=isWidth)
  131.     {
  132.         isWidth = isWidth*(mediacenter.videoZoom/100);
  133.         var nonVideoWidth = view.width - video1.width;
  134.         var newWindowWidth = isWidth+nonVideoWidth;
  135.         view.width = newWindowWidth;
  136.     }
  137.  
  138.     settingsDrawer.verticalAlignment    = "top";
  139.     playlistDrawer.horizontalAlignment  = "left";
  140. }
  141.  
  142.  
  143. function DoSize()
  144. {
  145.     if (movingDrawer == 0)
  146.     {
  147.         settingsDrawer.verticalAlignment    = "bottom";
  148.         playlistDrawer.horizontalAlignment  = "right";
  149.  
  150.         movingDrawer++;
  151.         view.size( 'bottomright' );
  152.         movingDrawer--;
  153.  
  154.         settingsDrawer.verticalAlignment    = "top";
  155.         playlistDrawer.horizontalAlignment  = "left";
  156.  
  157.         if (g_fNeedSnap)
  158.         {
  159.             DoSnapToSize();
  160.         }
  161.     }
  162. }
  163.  
  164. function SetAlignment( value )
  165. {
  166.     if (!value)
  167.     {
  168.         playerView.horizontalAlignment      = "left";
  169.         playerView.verticalAlignment        = "top";
  170.         playlistDrawer.verticalAlignment    = "top";
  171.     }
  172.     else
  173.     {
  174.         playerView.horizontalAlignment      = "stretch";
  175.         playerView.verticalAlignment        = "stretch";
  176.         playlistDrawer.verticalAlignment    = "stretch";
  177.     }
  178. }
  179.  
  180. function ToggleSettings()
  181. {
  182.     if(settingsIsOpen==true)
  183.     {
  184.         settingsDrawer.moveTo(settingsDrawer.left, view.height - bottomMove - settingsDrawer.height,1000);
  185.         settingsIsOpen=false;
  186.     }
  187.     else
  188.     {
  189.         SetAlignment( false );
  190.         view.maxHeight = event.screenHeight;
  191.         view.height += bottomMove;
  192.         view.minHeight = closedHeight + bottomMove;
  193.         SetAlignment( true );
  194.         settingsTab.visible = true;
  195.         settingsDrawer.moveTo(settingsDrawer.left,view.height - settingsDrawer.height,1000);
  196.         settingsIsOpen=true;
  197.         ChangeSettingsTab(0);
  198.     }
  199.     movingDrawer++;
  200.  }
  201.  
  202. function TogglePlaylist()
  203. {
  204.     if(playlistIsOpen==true)
  205.     {
  206.         playlist.visible=false;
  207.         playlistDrawer.moveTo(view.width - rightMove - playlistDrawer.width, playlistDrawer.top,1000);
  208.         playlistIsOpen=false;
  209.     }
  210.     else
  211.     {
  212.         SetAlignment( false );
  213.         view.maxWidth = event.screenWidth;
  214.         view.width += rightMove;
  215.         view.minWidth = closedWidth + rightMove;
  216.         SetAlignment( true );
  217.         playlistDrawer.moveTo(view.width - playlistDrawer.width, playlistDrawer.top,1000);
  218.         playlistIsOpen=true;
  219.     }
  220.     movingDrawer++;
  221. }
  222.  
  223. function OnModeChange()
  224. {
  225.     shuffle.down = player.settings.GetMode("shuffle");
  226. }
  227.  
  228. function EndDrawerMove()
  229. {
  230.     movingDrawer--;
  231.  
  232.     if (g_fNeedSnap)
  233.     {
  234.         DoSnapToSize();
  235.     }
  236. }
  237.  
  238. function Playlist_OnEndMove()
  239. {
  240.     if(playlistIsOpen==true)
  241.     {
  242.         playlist.visible=true;
  243.     }
  244.     else
  245.     {
  246.         playlist.visible=false;
  247.         SetAlignment( false );
  248.         view.minWidth = closedWidth;
  249.         view.width -= rightMove;
  250.         view.maxWidth = event.screenWidth - rightMove;
  251.         SetAlignment( true );
  252.     }
  253.     EndDrawerMove();
  254. }
  255.  
  256. function Settings_OnEndMove()
  257. {
  258.     if (!settingsIsOpen)
  259.     {
  260.         SRSSettings.visible = false;
  261.         AudioSettings.visible = false;
  262.         VideoSettings.visible = false;
  263.         settingsTab.visible   = false;
  264.         SetAlignment( false );
  265.         view.minHeight = closedHeight;
  266.         view.height -= bottomMove;
  267.         view.maxHeight = event.screenHeight - bottomMove;
  268.         SetAlignment( true );
  269.     }
  270.     EndDrawerMove();
  271. }
  272.  
  273. function ChangeSettingsTab(iWhichDir)
  274. {
  275.     var iPos = giSettingsPos;
  276.     iPos = iPos + iWhichDir;
  277.  
  278.     if (iPos < 0) 
  279.     {
  280.         iPos = gsSettingsNames.length -1;
  281.     } 
  282.     else if (iPos >= gsSettingsNames.length)
  283.     {
  284.         iPos = 0;
  285.     }
  286.     
  287.     if (settingsIsOpen)
  288.     {
  289.         switch (iPos)
  290.         {
  291.             case 0:
  292.                 AudioSettings.visible = false;
  293.                 VideoSettings.visible = false;
  294.                 SRSSettings.visible = true;
  295.                 tabTitle.value = "res://wmploc.dll/RT_STRING/#1827";
  296.                 break;
  297.  
  298.             case 1:
  299.                 SRSSettings.visible = false;
  300.                 VideoSettings.visible = false;
  301.                 AudioSettings.visible = true;
  302.                 tabTitle.value = "res://wmploc.dll/RT_STRING/#1848";
  303.                 break;
  304.  
  305.             case 2:
  306.                 SRSSettings.visible = false;
  307.                 AudioSettings.visible = false;
  308.                 VideoSettings.visible = true;
  309.                 tabTitle.value = "res://wmploc.dll/RT_STRING/#1849";
  310.                 break;
  311.         }
  312.     }
  313.  
  314.     giSettingsPos = iPos;    
  315. }
  316.  
  317. function OnShowTitles()
  318. {        
  319.     UpdateTitles();
  320.     SizeViz();
  321. }
  322.  
  323. function SizeViz()
  324. {
  325.     myeffect.top = mediacenter.showtitles ? 50 : 1;
  326.     var height = svScreen.height - myeffect.top - 24;
  327.     if (svBanner.visible)
  328.     {
  329.         myeffect.height -= svBanner.height;
  330.     }
  331.     myeffect.height = height;
  332. }
  333.  
  334. function UpdateTitles()
  335. {
  336.     if (!player.currentMedia) return;
  337.     if( (mediacenter.showtitles == true) && player.currentMedia.ImageSourceWidth == 0)
  338.     {
  339.         playlistArtist.visible = true;
  340.         trackname.visible = true;
  341.         playlistArtist.value = player.currentmedia.getiteminfo("artist");
  342.         trackname.value = player.currentmedia.name;
  343.         SizeViz();
  344.     }
  345.     else if(mediacenter.showtitles == false || player.currentMedia.ImageSourceWidth > 0)
  346.     {
  347.         playlistArtist.visible = false;
  348.         trackname.visible = false;
  349.         SizeViz();
  350.     }
  351. }
  352.  
  353. function OnDownloadingMediaViz(bstrItemName)
  354. {
  355.     if (bstrItemName=="WMPImage_AdBanner")
  356.     {
  357.         AdBanner.image=bstrItemName;
  358.         var strToolTip = player.currentmedia.getItemInfo("BannerAbstract");
  359.         AdBanner.upToolTip = strToolTip;
  360.     }
  361. }
  362.  
  363. function OnBannerClick()
  364. {
  365.     var strTargetURL = player.currentmedia.getItemInfo("BannerInfoURL");
  366.     if ( strTargetURL != "")
  367.     {
  368.         player.launchURL(strTargetURL);   
  369.     }
  370. }
  371.  
  372. function OnBannerMouseOver()
  373. {
  374.     if ( player.currentmedia.getItemInfo("BannerInfoURL") != "")
  375.     {
  376.         AdBanner.cursor = "hand";
  377.     }
  378.     else
  379.     {
  380.         AdBanner.cursor = "system";
  381.     }
  382. }
  383.  
  384. function VizPrev()
  385. {
  386.     if (event.shiftKey)
  387.     {
  388.         myeffect.previousEffect();
  389.     }
  390.     else
  391.     {
  392.         myeffect.previous();
  393.     }
  394.     SynchVis();
  395. }
  396.  
  397. function VizNext()
  398. {
  399.     if (event.shiftKey)
  400.     {
  401.         myeffect.nextEffect();
  402.     }
  403.     else
  404.     {
  405.         myeffect.next();
  406.     }
  407.     SynchVis();
  408. }
  409.  
  410. function OnStateChange()
  411. {
  412.     var osState = player.openState;
  413.  
  414.     if (osPlaylistOpenNoMedia == osState || osMediaChanging == osState || osPlaylistChanged == osState)
  415.     {
  416.         ShowVisualizations(false);
  417.         video1.visible=false;
  418.     }
  419.     else if (osMediaOpen == player.OpenState)
  420.     {
  421.         if (player.currentmedia.getItemInfo("BannerURL") != "")
  422.         {
  423.             ShowBanner(true);
  424.         }
  425.         else
  426.         {
  427.             ShowBanner(false);
  428.         }
  429.     
  430.         if (player.currentMedia.ImageSourceWidth > 0)
  431.         {
  432.             ShowVisualizations(false);
  433.             video1.visible=true;
  434.         } 
  435.         else 
  436.         { 
  437.             ShowVisualizations(true);
  438.             video1.visible=false;
  439.         }
  440.     }
  441.     else if (osPlaylistChanging == player.OpenState)
  442.     {
  443.         ShowVisualizations(false);
  444.         video1.visible=false;
  445.         ShowBanner(false);
  446.     }
  447.     UpdateTitles();
  448. }
  449.  
  450. function ShowVisualizations(state)
  451. {
  452.     if(state)
  453.     {
  454.         myeffect.visible=mediacenter.showEffects;
  455.         video1.visible=false;
  456.     }
  457.     else
  458.     {
  459.         myeffect.visible=false;
  460.     }
  461. }
  462.  
  463. function myOnVideoStart()
  464. {
  465.     video1.visible=true;
  466.     ShowVisualizations(false);
  467. }
  468.  
  469. function myOnVideoEnd()
  470. {
  471.     video1.visible=false;
  472.     ShowVisualizations(true);
  473. }
  474.  
  475. function ShowBanner(state)
  476. {
  477.     svBanner.visible = state;
  478. }
  479.  
  480. function SynchVis()
  481. {
  482.     var nPreset = myeffect.currentPreset;
  483.     mediacenter.effectType = myeffect.currentEffectType;
  484.     mediacenter.effectPreset = nPreset;
  485. }
  486.  
  487. function GetVizTitle()
  488. {
  489.     var CombinedTitle = myeffect.currentEffectTitle + ": " + myeffect.currentPresetTitle;
  490.     if (": " == CombinedTitle) CombinedTitle = "";
  491.     return CombinedTitle;
  492. }
  493.  
  494. var g_kAlphaToTime = 330;
  495. var g_kAlphaDisabled = 0x80;
  496.  
  497. function InitEQ()
  498. {
  499.     UpdateEQOnOff();
  500. }
  501.  
  502. function UpdateEQOnOff()
  503. {
  504.     if (eq.bypass == true)
  505.     {
  506.         nextPreset.enabled=false;
  507.         eqOnOffLabel.value="res://wmploc.dll/RT_STRING/#1851";
  508.     }
  509.     else
  510.     {
  511.         nextPreset.enabled=true;
  512.         eqOnOffLabel.value="res://wmploc.dll/RT_STRING/#1846";
  513.     }
  514. }
  515.  
  516. function InitSRS()
  517. {
  518.     UpdateSRSOnOff();
  519. }
  520.  
  521. function UpdateSRSOnOff()
  522. {
  523.  
  524.     if (eq.enhancedAudio == true)
  525.     {
  526.         nextSpeakerSize.enabled=true;
  527.         srsOnOffLabel.value="res://wmploc.dll/RT_STRING/#1846";
  528.     }
  529.     else
  530.     {
  531.         nextSpeakerSize.enabled=false;
  532.         srsOnOffLabel.value="res://wmploc.dll/RT_STRING/#1851";
  533.     }
  534.  
  535. }
  536.  
  537. function NextSpeakerSize()
  538. {
  539.     var index = eq.speakerSize;
  540.  
  541.     index++;
  542.     if (index > 2)
  543.         index = 0;
  544.  
  545.     eq.speakerSize = index;
  546. }
  547.  
  548. function ResetVideoSettings()
  549. {
  550.     vs.brightness=0;
  551.     vs.contrast=0;
  552.     vs.hue=0;
  553.     vs.saturation=0;
  554. }
  555.  
  556. function InitVideoSettingsView()
  557. {
  558.     if ( PlayingDVD() )
  559.     {
  560.         videoResetButton.enabled = false;
  561.         videoResetButton.alphaBlendTo(0x80,330); 
  562.     }
  563.     else
  564.     {
  565.         videoResetButton.enabled = true;
  566.         videoResetButton.alphaBlendTo(0xff,330); 
  567.     }
  568. }
  569.          
  570. function VideoSettings_OnOpenStateChangeEvent(NewState)
  571. {
  572.     switch (NewState)
  573.     {
  574.         case osPlaylistOpenNoMedia:
  575.         case osMediaOpen:
  576.             InitVideoSettingsView();
  577.             break;
  578.     }
  579. }
  580.  
  581. function DoShiftSensitiveEQ(level,newVal)
  582. {
  583.     if (eq.enableSplineTension && event.shiftKey) 
  584.     {
  585.         eq.enableSplineTension=false; 
  586.         eq.gainLevels(level) = newVal; 
  587.         eq.enableSplineTension=true;
  588.     }
  589. }
  590.  
  591. function PlayingDVD()
  592. {
  593.     return ( (player.currentPlaylist.count>0) && (player.currentPlaylist.item(0).sourceURL.indexOf("wmpdvd:")==0));
  594. }