mute.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #include <lib/std.mi>
  2. Function updateVolume(int v);
  3. Global Group frameGroup;
  4. Global Togglebutton MuteBtn,MuteBtnShade;
  5. Global Timer SongTickerTimer;
  6. Global Text InfoTicker;
  7. Global GuiObject SongTicker;
  8. Global Float VolumeLevel;
  9. Global Boolean Muted,BtnPressed;
  10. Global Layer volumebar;
  11. Global Timer callback;
  12. System.onScriptLoaded() {
  13. Muted = getPrivateInt("winamp5", "muted", 0);
  14. VolumeLevel = getPrivateInt("winamp5", "old_volume", 0);
  15. frameGroup = getScriptGroup();
  16. MuteBtn = frameGroup.findObject("mute");
  17. MuteBtn.setActivated(Muted);
  18. callback = new Timer; callback.setDelay(5); callback.start();
  19. SongTicker = frameGroup.findObject("songticker");
  20. InfoTicker = frameGroup.findObject("infoticker");
  21. volumebar = frameGroup.findObject("volumebar");
  22. volumebar.setXmlParam("w",integertostring( (system.getVolume()/255) *70 + 5));
  23. SongTickerTimer = new Timer;
  24. SongTickerTimer.setDelay(1000);
  25. if (Muted) {
  26. SongTickerTimer.start();
  27. SongTicker.hide();
  28. InfoTicker.show();
  29. InfoTicker.setText("Mute ON");
  30. }
  31. BtnPressed = 0;
  32. }
  33. System.onScriptUnloading() {
  34. setPrivateInt("winamp5", "muted", Muted);
  35. setPrivateInt("winamp5", "old_volume", VolumeLevel);
  36. delete callback;
  37. }
  38. callback.onTimer() {
  39. MuteBtnShade = getcontainer("main").getlayout("shade").findObject("shademute");
  40. if (MuteBtnShade != NULL) {
  41. MuteBtnShade.setActivated(Muted);
  42. stop();
  43. }
  44. }
  45. SongTickerTimer.onTimer() {
  46. SongTicker.show();
  47. InfoTicker.hide();
  48. SongTickerTimer.stop();
  49. }
  50. MuteBtn.onLeftClick() {
  51. BtnPressed = 1;
  52. if (!Muted) {
  53. VolumeLevel = System.getVolume();
  54. System.setVolume(0);
  55. Muted = 1;
  56. SongTickerTimer.start();
  57. SongTicker.hide();
  58. InfoTicker.show();
  59. InfoTicker.setText("Mute ON");
  60. MuteBtnShade.setActivated(1);
  61. } else {
  62. System.setVolume(VolumeLevel);
  63. Muted = 0;
  64. SongTickerTimer.start();
  65. SongTicker.hide();
  66. InfoTicker.show();
  67. InfoTicker.setText("Mute OFF");
  68. MuteBtnShade.setActivated(0);
  69. }
  70. }
  71. MuteBtnShade.onLeftClick() {
  72. BtnPressed = 1;
  73. if (!Muted) {
  74. VolumeLevel = System.getVolume();
  75. System.setVolume(0);
  76. Muted = 1;
  77. SongTickerTimer.start();
  78. SongTicker.hide();
  79. InfoTicker.show();
  80. InfoTicker.setText("Mute ON");
  81. MuteBtn.setActivated(1);
  82. } else {
  83. System.setVolume(VolumeLevel);
  84. Muted = 0;
  85. SongTickerTimer.start();
  86. SongTicker.hide();
  87. InfoTicker.show();
  88. InfoTicker.setText("Mute OFF");
  89. MuteBtn.setActivated(0);
  90. }
  91. }
  92. System.onScriptUnloading() {
  93. delete SongTickerTimer;
  94. }
  95. System.onvolumechanged(int newvol)
  96. {
  97. volumebar.setXmlParam("w",integertostring( (newvol/255) *70 + 5));
  98. if (!BtnPressed) {
  99. SongTickerTimer.start();
  100. SongTicker.hide();
  101. InfoTicker.show();
  102. InfoTicker.setText(translate("Volume") + ": " + integerToString(newvol/2.55) + "%");
  103. if (Muted) {
  104. MuteBtn.setActivated(0);
  105. MuteBtnShade.setActivated(0);
  106. Muted = 0;
  107. }
  108. }
  109. BtnPressed = 0;
  110. }