1
0

mute.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: mute.m
  4. Version: 1.1
  5. Type: maki
  6. Date: 13. Jun. 2007 - 12:39
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. Note: This script is based on mute.m
  12. from Winamp Modern
  13. -----------------------------------------------------
  14. ---------------------------------------------------*/
  15. #include <lib/std.mi>
  16. #define GLOW_OBJECT MuteButton
  17. #include <lib/com/glow.m>
  18. Class Button GlowButton;
  19. Global int VOLUME_FILL_MAX_W;
  20. Global Group frameGroup;
  21. Global Button MuteBtn, DeMuteBtn;
  22. Global GuiObject SongTicker;
  23. Global Float VolumeLevel;
  24. Global Boolean Muted,BtnPressed;
  25. Global GuiObject fill;
  26. Global GuiObject muteActive;
  27. Global Int muteActive_Y;
  28. Global Boolean demuteDown;
  29. Global Boolean isShade;
  30. System.onScriptLoaded()
  31. {
  32. frameGroup = system.getScriptGroup();
  33. isShade = (frameGroup.getParentlayout().getID() == "shade");
  34. MuteBtn = frameGroup.findObject("mute");
  35. DeMuteBtn = frameGroup.findObject("etum");
  36. fill = frameGroup.findObject("player.volume.fill");
  37. muteActive = frameGroup.findObject("mute.active");
  38. SongTicker = frameGroup.findObject("songticker");
  39. if (!isShade) muteActive_Y = muteActive.getGuiY();
  40. if (!isShade) _MuteButton_GlowInit (MuteBtn, frameGroup.findObject("mute.glow"), 0.3);
  41. if (!isShade) _MuteButton_addTrigger (DeMuteBtn);
  42. Muted = getPrivateInt("winamp5", "muted", 0);
  43. VolumeLevel = getPrivateInt("winamp5", "old_volume", 0);
  44. VOLUME_FILL_MAX_W = stringToInteger(getParam());
  45. fill.setXmlParam("w", integerToString(VOLUME_FILL_MAX_W*getVolume()/255));
  46. if (Muted)
  47. {
  48. SongTicker.sendAction("showinfo", "Mute ON", 0, 0, 0, 0);
  49. MuteBtn.hide();
  50. DeMuteBtn.show();
  51. if (!isShade) muteActive.show();
  52. }
  53. else
  54. {
  55. MuteBtn.show();
  56. DeMuteBtn.hide();
  57. if (!isShade) muteActive.hide();
  58. }
  59. BtnPressed = 0;
  60. }
  61. System.onScriptUnloading()
  62. {
  63. setPrivateInt("winamp5", "muted", Muted);
  64. setPrivateInt("winamp5", "old_volume", VolumeLevel);
  65. }
  66. MuteBtn.onLeftClick()
  67. {
  68. BtnPressed = 1;
  69. VolumeLevel = System.getVolume();
  70. System.setVolume(0);
  71. Muted = 1;
  72. DeMuteBtn.show();
  73. MuteBtn.hide();
  74. if (!isShade) muteActive.show();
  75. }
  76. MuteBtn.onLeftButtonDown (int x, int y)
  77. {
  78. SongTicker.sendAction("showinfo", "Mute: Off", 0, 0, 0, 0);
  79. }
  80. DeMuteBtn.onLeftButtonDown (int x, int y)
  81. {
  82. SongTicker.sendAction("showinfo", "Mute: On", 0, 0, 0, 0);
  83. if (!isShade) demuteDown = 1;
  84. if (!isShade) muteActive.setXmlParam("y", integerToString(muteActive_Y+1));
  85. }
  86. MuteBtn.onLeftButtonUp (int x, int y)
  87. {
  88. if (Muted) SongTicker.sendAction("showinfo", "Mute: On", 0, 0, 0, 0);
  89. }
  90. DeMuteBtn.onLeftButtonUp (int x, int y)
  91. {
  92. if (!Muted) SongTicker.sendAction("showinfo", "Mute: Off", 0, 0, 0, 0);
  93. if (!isShade) demuteDown = 0;
  94. if (!isShade) muteActive.setXmlParam("y", integerToString(muteActive_Y));
  95. }
  96. DeMuteBtn.onLeftClick()
  97. {
  98. BtnPressed = 1;
  99. System.setVolume(VolumeLevel);
  100. Muted = 0;
  101. DeMuteBtn.hide();
  102. MuteBtn.show();
  103. if (!isShade) muteActive.hide();
  104. }
  105. DeMuteBtn.onleaveArea ()
  106. {
  107. if (!isShade) muteActive.setXmlParam("y", integerToString(muteActive_Y));
  108. }
  109. DeMuteBtn.onEnterArea ()
  110. {
  111. if (!isShade && demuteDown) muteActive.setXmlParam("y", integerToString(muteActive_Y+1));
  112. }
  113. System.onvolumechanged(int newvol)
  114. {
  115. fill.setXmlParam("w", integerToString(VOLUME_FILL_MAX_W*getVolume()/255));
  116. if (!BtnPressed)
  117. {
  118. SongTicker.sendAction
  119. (
  120. "showinfo",
  121. translate("Volume") + ": " + integerToString(newvol/2.55) + "%",
  122. 0, 0, 0, 0
  123. );
  124. if (Muted)
  125. {
  126. Muted = 0;
  127. MuteBtn.show();
  128. DeMuteBtn.hide();
  129. if (!isShade) muteActive.hide();
  130. }
  131. }
  132. BtnPressed = 0;
  133. }