albumart.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: albumart.m
  4. Version: 1.1
  5. Type: maki
  6. Date: 20. Sep. 2007 - 16:54
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. -----------------------------------------------------
  12. ---------------------------------------------------*/
  13. #include <lib/std.mi>
  14. #include <lib/com/songinfo.m>
  15. #define WEBCOVER_SHOUTCAST "winamp.cover.shoutcast"
  16. Function loadFileInfo();
  17. //Function loadPlaylistArtWork();
  18. Global Int plArtRetries = 0;
  19. Global Group scriptGroup;
  20. Global AlbumArtLayer l_albumart;
  21. Global String notfoundImage = "winamp.cover.notfound.xxl";
  22. System.onScriptLoaded ()
  23. {
  24. scriptGroup = getScriptGroup();
  25. l_albumart = scriptGroup.findObject(getToken(getParam(), ",", 0));
  26. notfoundImage = getToken(getParam(), ",", 1);
  27. loadFileInfo();
  28. }
  29. l_albumart.onRightButtonDown (int x, int y)
  30. {
  31. popupmenu p = new popupmenu;
  32. p.addCommand("Refresh Album Art", 1, 0, 0);
  33. String path = getPath(getPlayItemMetaDataString("filename"));
  34. if(path != "")
  35. {
  36. p.addCommand("Open Folder", 2, 0, 0);
  37. }
  38. int result = p.popatmouse();
  39. delete p;
  40. if (result == 1)
  41. {
  42. l_albumart.refresh();
  43. }
  44. else if (result == 2)
  45. {
  46. if(path != "")
  47. {
  48. System.navigateUrl(path);
  49. }
  50. else
  51. {
  52. String url = getPlayItemMetaDataString("streamurl");
  53. if(url != "")
  54. {
  55. System.navigateUrl(url);
  56. }
  57. }
  58. }
  59. }
  60. l_albumart.onLeftButtonDblClk (int x, int y)
  61. {
  62. String path = getPath(getPlayItemMetaDataString("filename"));
  63. if(path != "")
  64. {
  65. System.navigateUrl(path);
  66. }
  67. else
  68. {
  69. String url = getPlayItemMetaDataString("streamurl");
  70. if(url != "")
  71. {
  72. System.navigateUrl(url);
  73. }
  74. }
  75. }
  76. loadFileInfo ()
  77. {
  78. songinfo_reload(); // refresh vars
  79. plArtRetries = 0;
  80. l_albumart.setXMLParam("notfoundImage", notfoundImage);
  81. //debugInt(songinfo_isStream);
  82. if (songinfo_isStream)
  83. {
  84. // setCover either from a supplied url or from in-stream artwork or default to a generic image
  85. if (songinfo_streamAlbumArt != "")
  86. {
  87. l_albumart.setXMLParam("image", songinfo_streamAlbumArt);
  88. l_albumart.setXMLParam("notfoundImage", notfoundImage);
  89. }
  90. if(songinfo_streamType == SONGINFO_STREAMTYPE_SHOUTCAST || songinfo_streamType == SONGINFO_STREAMTYPE_SHOUTCAST2)
  91. {
  92. if(songinfo_streamType == SONGINFO_STREAMTYPE_SHOUTCAST2)
  93. {
  94. if(l_albumart.isInvalid() && plArtRetries < 5)
  95. {
  96. if(!plArtRetries)
  97. {
  98. l_albumart.setXMLParam("notfoundImage", WEBCOVER_SHOUTCAST);
  99. }
  100. plArtRetries += 1;
  101. l_albumart.refresh();
  102. }
  103. }
  104. else
  105. {
  106. l_albumart.setXMLParam("notfoundImage", WEBCOVER_SHOUTCAST);
  107. }
  108. }
  109. }
  110. }
  111. // Hide branding of we start playback
  112. System.onPlay ()
  113. {
  114. loadFileInfo();
  115. }
  116. System.onTitleChange (String newtitle)
  117. {
  118. loadFileInfo();
  119. }