seek.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: seek.m
  4. Version: 1.2
  5. Type: maki
  6. Date: 23. Jul. 2007 - 22:52
  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 seek.m
  12. from Winamp Modern
  13. -----------------------------------------------------
  14. ---------------------------------------------------*/
  15. #include <lib/std.mi>
  16. Global Group frameGroup;
  17. Global Slider Seeker, SeekerBehind;
  18. Global Int Seeking;
  19. Global GuiObject SongTicker;
  20. Global GuiObject progressBar;
  21. System.onScriptLoaded()
  22. {
  23. frameGroup = system.getScriptGroup();
  24. Seeker = frameGroup.findObject("seeker.ghost");
  25. SeekerBehind = frameGroup.findObject("seeker.ghost");
  26. progressBar = frameGroup.findObject("progressbar");
  27. SongTicker = frameGroup.getParentLayout().findObject("songticker");
  28. progressBar.hide();
  29. progressBar.show();
  30. if (getStatus() == 0 || !seeker.isvisible())
  31. {
  32. progressBar.hide();
  33. }
  34. }
  35. Seeker.onSetPosition(int p) {
  36. if (seeking) {
  37. Float f;
  38. f = p;
  39. f = f / 255 * 100;
  40. Float len = getPlayItemLength();
  41. if (len != 0) {
  42. int np = len * f / 100;
  43. SongTicker.sendAction
  44. (
  45. "showinfo",
  46. translate("Seek") + ": " + integerToTime(np) + "/" + integerToTime(len) + " (" + integerToString(f) + "%) ",
  47. 0, 0, 0, 0
  48. );
  49. }
  50. }
  51. }
  52. /** Hehe, this is the best trick i figured out to indicate if we have a stream */
  53. Seeker.onSetVisible (Boolean onoff)
  54. {
  55. if (onoff)
  56. {
  57. progressBar.show();
  58. }
  59. else
  60. {
  61. progressBar.hide();
  62. }
  63. }
  64. Seeker.onLeftButtonDown(int x, int y) {
  65. seeking = 1;
  66. Seeker.setAlpha(128);
  67. SeekerBehind.show();
  68. }
  69. Seeker.onLeftButtonUp(int x, int y) {
  70. seeking = 0;
  71. Seeker.setAlpha(255);
  72. SeekerBehind.hide();
  73. SongTicker.sendAction("cancelinfo", "", 0, 0, 0, 0);
  74. }
  75. Seeker.onSetFinalPosition(int p) {
  76. SongTicker.sendAction("cancelinfo", "", 0, 0, 0, 0);
  77. }